๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.59K photos
3 videos
95 files
10.2K 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
int findmaximumPackages(vector<int>&arr)
{
    int n = arr.size();
    int mx = *max_element(arr.begin(), arr.end());
    mx = mx * 2;
    int res = 0;
    map<int, int>mp;
    for (auto it : arr) {
        mp[it]++;
    }
    for (int i = 1; i <= mx; i++) {
        int sm = 0;
        for (int j = 1; j <= (i - 1) / 2; j++) {
            sm += min(mp[j], mp[i - j]);
        }
        if (i % 2 == 0) {
            sm += (mp[i / 2] / 2);
        }
        res = max(res, mp[i] + sm);
    }
    return res;
}

Amazon โœ…
public static long getMaxXor(long n) {
    if (n == 0) {
        return 0;
    }
    int x = 0;
    while (n >> x > 0) {
        x++;
    }
    return (1L << x) - 2;
    
   }

IBMโœ…
#include<bits/stdc++.h>
using namespace std;

long long m = 100000000000000000;

int minOperations(vector<int> &arr)
{
    int n=arr.size();
    if(n == 1) return 0;

    if(n == 2) return arr[0]+arr[1]<0;

    int cnt = 0;

    long long prev,curr,next;

    prev = m;
    curr = arr[0];
    next = arr[1];

    int ind = 1;

    while(ind<n)
    {  
        if(prev+curr+next<0 || curr+next<0)
        {
            prev = curr;
            curr = m;
            cnt++;
        }else{
            prev = curr;
            curr = next;
        }

        if(ind<n) next = arr[ind+1];
        ind++;
    }

    return cnt;
}


UKG โœ…
Make the Array Positive
def find_consecutive_sets(n):
    result = []
    count = 0

    for i in range(1, n//2 + 2):
        sum_ = 0
        temp = []
       
        for j in range(i, n + 1):
            sum_ += j
            temp.append(j)
           
            if sum_ == n:
                result.append(temp[:])
                count += 1
                break
            elif sum_ > n:
                break

    result.reverse()

    for seq in result:
        print(" ".join(map(str, seq)))
   
    print(count)

n = int(input())
find_consecutive_sets(n)


Deloitte โœ