๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.61K photos
3 videos
95 files
10.6K links
๐ŸšฉMain Group - @SuperExams
๐Ÿ“Job Updates - @FresherEarth

๐Ÿ”ฐAuthentic Coding Solutions(with Outputs)
โš ๏ธDaily Job Updates
โš ๏ธHackathon Updates & Solutions

Buy ads: https://telega.io/c/cs_algo
Download Telegram
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
long findMaximumEarning(vector<int> send, vector<int> receive, vector<int> amount, vector<int> capacity) {
    int n = send.size();
    int m = capacity.size();
   
    vector<tuple<int, int, int>> tasks;
    for (int i = 0; i < n; i++) {
        tasks.push_back(make_tuple(max(send[i], receive[i]), amount[i], i));
    }
   
    sort(tasks.begin(), tasks.end(), [](const auto& a, const auto& b) {
        return get<1>(a) > get<1>(b);
    });
   
    sort(capacity.begin(), capacity.end());
   
    long totalEarnings = 0;
   
    vector<bool> used(m, false);
   
    for (const auto& task : tasks) {
        int taskData = get<0>(task);
        int taskEarning = get<1>(task);
       
        for (int i = 0; i < m; i++) {
            if (!used[i] && capacity[i] >= taskData) {
                totalEarnings += taskEarning;
                used[i] = true;
                break;
            }
        }
    }
   
    return totalEarnings;
}
long eqalize(vector<long>power)
{
  int n = power.size();
  sort(power.begin(), power.end());
  long val = 0;
  if (n % 2 == 1) {
    val = power[n / 2];
  }
  else {
    val = (power[(n - 1) / 2] + power[n / 2]) / 2;
  }
  long res = 0;
  for (long i = 0; i < n; ++i)
  {
    res += abs(power[i] - val);
  }
  return res;
}
SELECT 
    ROUND(
        (COUNT(CASE WHEN polygon_name = 'Adarsh Palm Retreat' THEN 1 END) * 100.0) /
        COUNT(*),
        2
    ) AS order_share
FROM
    POLYGON
WHERE
    order_date = '2020-12-31';

Swiggy Order share โœ…
SELECT 
    'within 100' AS BUCKET,
    COUNT(*) AS Orders
FROM cuisine_orders
WHERE item_total <= 100

UNION ALL

SELECT
    'within 150' AS BUCKET,
    COUNT(*) AS Orders
FROM cuisine_orders
WHERE item_total <= 150

UNION ALL

SELECT
    'within 200' AS BUCKET,
    COUNT(*) AS Orders
FROM cuisine_orders
WHERE item_total <= 200

ORDER BY BUCKET;

Swiggy Bucket wise order โœ…
๐Ÿ‘1
def minMoves(h, w, h1, w1):
    if h1 > h or w1 > w:
        return -1
    moves = 0
    while h > h1:
        h = (h + 1) // 2
        moves += 1
    while w > w1:
        w = (w + 1) // 2
        moves += 1
    return moves
We're looking for an intern to work on a vision project at Mercedes Benz R&D India (MBRDI). The candidate should be available for 6 months (on site preferred) and should have some prior research experience and knowhow of latest vision trends like NeRF, SAM, CLIP, etc. Please DM a detailed paragraph of your research experience along with your CV or drop me an email at : vasudev.singh@mercedes-benz.com
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
def calculate_prefix_sums(arr):
    prefix_sums = [0] * len(arr)
    prefix_sums[0] = arr[0]
    for i in range(1, len(arr)):
        prefix_sums[i] = prefix_sums[i - 1] + arr[i]
    return prefix_sums

def count_balanced_partitions(prefix_sums):
    total_sum = prefix_sums[-1]
    count = 0
    for i in range(len(prefix_sums) - 1):
        if prefix_sums[i] == (total_sum - prefix_sums[i]):
            count += 1
    return count

def max_balanced_partitions(arr, k):
    n = len(arr)
    if n < 2:
        return 0

    prefix_sums = calculate_prefix_sums(arr)
    original_count = count_balanced_partitions(prefix_sums)
   
    max_count = original_count
   
    for i in range(n):
        new_arr = arr[:]
        new_arr[i] = k
        new_prefix_sums = calculate_prefix_sums(new_arr)
        new_count = count_balanced_partitions(new_prefix_sums)
        max_count = max(max_count, new_count)
   
    return max_count

The dice roll challenge โœ…
def maxPerformance(self, n: int, speed: List[int], efficiency: List[int], k: int) -> int:
       
        cur_sum, h = 0, []
        ans = -float('inf')
       
        for i, j in sorted(zip(efficiency, speed),reverse=True):
            while len(h) > k-1:
                cur_sum -= heappop(h)
            heappush(h, j)
            cur_sum += j
            ans = max(ans, cur_sum * i)
           
        return ans % (10**9+7)

Tasty Dishes โœ…
๐Ÿ‘1
def maxPosPrefixes(arr):
    arr.sort(reverse=True)
    prefix_sum = 0
    positive_count = 0
    for num in arr:
        prefix_sum += num
        if prefix_sum > 0:
            positive_count += 1
        else:
            break 
    return positive_count


Positive prefixes Adobe โœ…
ll cmp(const void *a, const void *b) {
    return (*(ll*)a - *(ll*)b);
}
ll solve(vector<ll> a, ll k) {
    ll n = a.size();
    if (k < 2 || n < 2 * k - 1) return -1;
    vector<ll> s = a;
    qsort(s.data(), n, sizeof(ll), cmp);

    for (ll t = k - 1; t < n; ++t) {
        ll i = -1;
        while (a[++i] != s[t]);

        ll sz = 1;
        ll li = i;
       
        for (ll u = i; u >= 0; --u) {
            if (u < li - 1 && a[u] <= s[t]) {
                ++sz;
                li = u;
            }
            if (sz >= k) return s[t];
        }

        li = i;
        for (ll u = i; u < n; ++u) {
            if (u > li + 1 && a[u] <= s[t]) {
                ++sz;
                li = u;
            }
            if (sz >= k) return s[t];
        }
    }
    return -1;
}

//vulnerability