๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
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
def solution(menu, order):

    t_cost = 0
    for item in order:
        pizza = next(p for p in menu if p.name == item.name)
        price = getattr(pizza, f'price_{item.size[0]}')
        total_cost += price * item.quantity
    total_pizzas = sum(item.quantity for item in order)
    if total_pizzas >= 3:
        cheapest_price = min(getattr(next(p for p in menu if p.name == item.name), f'price_{item.size[0]}')
                             for item in order)
        discounted_cost = t_cost - cheapest_price
        return min(t_cost, discounted_cost)
    return t_cost
def findMaxLength(str1, str2, str3):
    m, n = len(str1), len(str2)
   
    dp = [[0] * (n + 1) for _ in range(m + 1)]
   
    for i in range(1, m + 1):
        for j in range(1, n + 1):
            if str1[i-1] == str2[j-1]:
                if not has_common_substring(str1[:i], str2[:j], str3):
                    dp[i][j] = dp[i-1][j-1] + 1
                else:
                    dp[i][j] = max(dp[i-1][j], dp[i][j-1])
            else:
                dp[i][j] = max(dp[i-1][j], dp[i][j-1])
   
    return dp[m][n]

def has_common_substring(s1, s2, s3):
    if len(s1) >= 2 and len(s2) >= 2:
        last_two = s1[-2:]
        if last_two in s3 and last_two == s2[-2:]:
            return True
    return False

DE Shaw โœ…
๐Ÿ‘1
def isPrime(n):
    if n < 2:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True

def endsWithThree(n):
    return n % 10 == 3

def maxGameScore(cell):
    n = len(cell)
    dp = [float('-inf')] * n
    dp[0] = cell[0] 
   
    for i in range(1, n):
        dp[i] = max(dp[i], dp[i-1] + cell[i])

        for j in range(i):
            jump = i - j
            if isPrime(jump) and endsWithThree(jump):
                dp[i] = max(dp[i], dp[j] + cell[i])
   
    return dp[n-1]

Prime jumps โœ