๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.58K subscribers
5.59K photos
3 videos
95 files
10.1K 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
typedef long long ll;
long findMinIncrease(vector<int> threadSize) {
    int n = threadSize.size();
    if(n < 3) return 0;

    vector<ll> required_increase(n, 0);
    for(int i=1; i<n-1; ++i){
        ll needed = max((ll)threadSize[i-1], (ll)threadSize[i+1]) + 1;
        if(threadSize[i] < needed){
            required_increase[i] = needed - (ll)threadSize[i];
        }
        else{
            required_increase[i] = 0;
        }
    }

    pair<int, ll> prev0 = {0, 0};
    pair<int, ll> prev1 = {-1, 0};

    for(int i=0; i<n; ++i){
        pair<int, ll> current0 = {0, 0};
        pair<int, ll> current1 = {0, 0};

        if(i == 0 || i == n-1){
            if(prev0.first > prev1.first){
                current0 = prev0;
            }
            else if(prev0.first < prev1.first){
                current0 = prev1;
            }
            else{
                current0.first = prev0.first;
                current0.second = min(prev0.second, prev1.second);
            }
            prev0 = current0;
            prev1 = {-1, 0};
            continue;
        }

        if(prev0.first > prev1.first){
            current0.first = prev0.first;
            current0.second = prev0.second;
        }
        else if(prev0.first < prev1.first){
            current0.first = prev1.first;
            current0.second = prev1.second;
        }
        else{
            current0.first = prev0.first;
            current0.second = min(prev0.second, prev1.second);
        }

        if(prev0.first != -1){
            current1.first = prev0.first + 1;
            current1.second = prev0.second + required_increase[i];
        }
        else{
            current1.first = -1;
            current1.second = 0;
        }

        pair<int, ll> new_prev0 = current0;
        pair<int, ll> new_prev1;
        if(current1.first != -1){
            new_prev1 = current1;
        }
        else{
            new_prev1 = {-1, 0};
        }

        prev0 = new_prev0;
        prev1 = new_prev1;
    }

    pair<int, ll> final_ans;
    if(prev0.first > prev1.first){
        final_ans = prev0;
    }
    else if(prev0.first < prev1.first){
        final_ans = prev1;
    }
    else{
        final_ans.first = prev0.first;
        final_ans.second = min(prev0.second, prev1.second);
    }

    return final_ans.second;
}

LinkedIn โœ…
๐Ÿ‘1
#define INF INT_MAX

int minimumStressLevel(int N, vector<vector<int>>& abw, int X, int Y) {
   
    vector<vector<pair<int, int>>> graph(N + 1);
    for (auto& road : abw) {
        int a = road[0], b = road[1], w = road[2];
        graph[a].push_back({b, w});
        graph[b].push_back({a, w});
    }
    
  
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    vector<int> dist(N + 1, INF);
    pq.push({0, X});
    dist[X] = 0;

    while (!pq.empty()) {
        int u = pq.top().second;
        int stress = pq.top().first;
        pq.pop();

        if (u == Y) return stress;

        for (auto& neighbor : graph[u]) {
            int v = neighbor.first;
            int w = neighbor.second;
            int new_stress = max(stress, w);
            if (new_stress < dist[v]) {
                dist[v] = new_stress;
                pq.push({new_stress, v});
            }
        }
    }

    return -1; 
}

ROBIN HOODโœ…
Probo (Intern)
๐Ÿ‘1
#include <bits/stdc++.h>
using namespace std;

string getPerfectExecutionString(string& category) {
    vector<int> freq(26, 0);
    for (char& x : category) {
        freq[x - 'a']++;
    }

    string temp;
    string ans;
    int p = 0; 

    for (int i = 0; i < 26; i++) {
        while (!temp.empty() && temp.back() - 'a' <= i) {
            ans.push_back(temp.back());
            temp.pop_back();
        }

        while (freq[i]) {
            if (category[p] - 'a' == i) {
                ans.push_back(category[p]);
            } else {
                temp.push_back(category[p]);
            }
            freq[category[p++] - 'a']--;
        }
    }

    while (!temp.empty()) {
        ans.push_back(temp.back());
        temp.pop_back();
    }

    return ans;
}


Get perfect executing string โœ…
DE Shaw
void dfs(vll &arr,int n,int m,int i,int j,vl &ans,ll val,ll mini){
    if(i==n-1 and j==m-1){
        ans.pb(mini);
        return;
    }
    if(i+1<n and j<m){
        dfs(arr,n,m,i+1,j,ans,val+arr[i+1][j],min(mini,val+arr[i+1][j]));
    }
    if(i<n and j+1<m){
        dfs(arr,n,m,i,j+1,ans,val+arr[i][j+1],min(mini,val+arr[i][j+1]));
    }
}
void solve()
{
    ll n,m;
    cin>>n>>m;
    vll arr(n,vl(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>arr[i][j];
        }
    }
    vl ans;
    dfs(arr,n,m,0,0,ans,arr[0][0],arr[0][0]);
    sort(all(ans));
    if(ans[0]>0){
        cout<<0<<endl;
        return;
    }
    cout<<abs(ans[0])+1<<endl;
    debug(ans);
}

Mario โœ…
โค1๐Ÿ”ฅ1
class Chief:
    @classmethod
    def poloChampionship(cls, input1, input2, input3, input4, input5):
        N = input1 
        D = input2
        R = input3
        X = input4
        C = input5

        dail = N * R
        maxi = max(D)
        tot = 0

        if maxi <= X:
            tot = sum(D) * C
        else:
            tot = N * X * C

        lon = R + tot
        return min(dail, lon)


Polo Championship โœ…
class FibonacciIterator:
    def __init__(self, n):
        self.prev = 0 
        self.curr = 1 
        self.count = 0 
        self.n = n 

    def __iter__(self):
        return self

    def __next__(self):
        if self.count >= self.n:
            raise StopIteration
        fib = self.prev
        self.prev, self.curr = self.curr, self.prev + self.curr 
        self.count += 1
        return fib


Custom Iterator โœ…
Servicenow
def priceCheck(products, productPrices, productSold, soldPrice):
    price_map = {}
    for i in range(len(products)):
        price_map[products[i]] = productPrices[i]
    error_count = 0
    for j in range(len(productSold)):
        correct_price = price_map[productSold[j]] 
        if soldPrice[j] != correct_price:
            error_count += 1
    return error_count


IBMโœ