๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.57K subscribers
5.58K photos
3 videos
95 files
9.98K 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
def stemmer(text):
    words = text.split()
    result = []
    for word in words:
        if word.endswith('ed'):
            word = word[:-2]
        elif word.endswith('ly'):
            word = word[:-2]
        elif word.endswith('ing'):
            word = word[:-3]
        if len(word) > 8:
            word = word[:8]
        result.append(word)
    return ' '.join(result)


Suffle stripping Stemmer โœ…
๐Ÿ‘1
import math
def rooter():
    while True:
        x = (yield)
        yield math.isqrt(x) 

def squarer():
    while True:
        x = (yield)
        yield x * x

def accumulator():
    total = 0
    while True:
        x = (yield)
        total += x
        yield total


Square accumulate root โœ…
๐Ÿคฎ2
int countK(vector<int> rank,int n,int k){
    int res = 0,curSum=0;
   
    unordered_map<int,int> mp;
   
    for(int i=0;i<n;i++){
       curSum += (rank[i]-k);
       if(curSum == 0) res++;
      
       if(mp.find(curSum) != mp.end()){
           res += mp[curSum];
       }
       mp[curSum]++;
    }
return res;
}


vector<int> getMeanRankCount(vector<int> rank){
    int n = rank.size();
   
    vector<int> ans;
   
    for(int i=1;i<=n;i++){
        ans.push_back(countK(rank,n,i));
    }
return ans;
}

Amazon โœ…
๐Ÿ‘2
SELECT 
    empld,
    department,
    performance_rating
FROM
    Permanent
WHERE
    experience >= 5
    AND performance_rating > 85

UNION

SELECT
    empld,
    department,
    performance_rating
FROM
    Contractual
WHERE
    contract_duration >= 12
    AND performance_rating > 90

ORDER BY
    empld;

Annual salary
Meesho โœ…
WITH AvailableRooms AS (
    SELECT roomId, viewType
    FROM Rooms
    WHERE availability = 'Available'
)

SELECT g.guestId, g.name, r.roomId
FROM Guests g
JOIN AvailableRooms r
ON g.viewPreference = r.viewType
ORDER BY g.guestId, r.roomId

Hotel room allocation
Meesho โœ…
SELECT COUNT(DISTINCT ts.rollno) AS Pending
FROM TotalStudents ts
LEFT JOIN offcampus oc ON ts.rollno = oc.rollno AND oc.approved = 'NO'
LEFT JOIN oncampus oncamp ON ts.rollno = oncamp.rollno
LEFT JOIN PG pg ON ts.rollno = pg.rollno
WHERE ts.percentage > 65
  AND ts.backlog = 'NO'
  AND oncamp.rollno IS NULL
  AND pg.rollno IS NULL
  AND oc.rollno IS NOT NULL;

yet to be placed
Meesho โœ…
๐Ÿคฎ1
from typing import List
def findMissingOperationIndex(ops: List[str], missingOp: str, currentTop: int) -> int:
    n = len(ops)
    def simulate_stack(ops_with_insert: List[str]) -> int:
        stack = []
        for op in ops_with_insert:
            if op.startswith("PUSH"):
                _, x = op.split()
                stack.append(int(x))
            elif op == "POP":
                if stack:
                    stack.pop()
        return stack[-1] if stack else None
    for i in range(n + 1):
        ops_with_insert = ops[:i] + [missingOp] + ops[i:]
        final_top = simulate_stack(ops_with_insert)
        if final_top == currentTop:
            return i
    return -1


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

bool isVowel(char a) {
    return a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u';
}

long vowelSubstring(string a) {
    int b[26] = {0};
    int c = 0, d = 0, e = 0;
    long f = 0;

    while (d < a.length()) {
        char g = a[d];

        if (isVowel(g)) {
            if (b[g - 'a'] == 0) {
                e++;
            }
            b[g - 'a']++;

            if (e == 5) {
                int h = c;
                int i[26];
                memcpy(i, b, sizeof(i));

                while (e == 5) {
                    f++;

                    char j = a[h];
                    i[j - 'a']--;
                    if (i[j - 'a'] == 0) {
                        e--;
                    }
                    h++;
                }
                e = 5;
            }
        } else {
            c = d + 1;
            e = 0;
            memset(b, 0, sizeof(b));
        }
        d++;
    }
    return f;
}


Aptiv โœ…
๐Ÿ‘1
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
   
    ll m, n;
    cin >> m >> n;
   
    vector<ll> cars(m);
    for(auto &x: cars) cin >> x;
   
    sort(cars.begin(), cars.end());
   
    ll coverage = 0;
    int added = 0;
    int i = 0;
   
    while(coverage < n){
      
        if(i < m && cars[i] <= coverage + 1){
            coverage += cars[i];
            i++;
        }
        else{
          
            ll new_car = coverage + 1;
            coverage += new_car;
            added++;
            if(coverage > n) coverage = n;
        }
    }
   
    cout << added;
}
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
static final int MOD = 1000000007;

    public static int getNumPerfectPackaging(int[] prices) {
        int n = prices.length;
        if (n == 0) return 0;
        if (n == 1) return 5;

        long[] dpPrev = new long[6]; // index 1 to 5
        for(int s = 1; s <=5; s++) {
            dpPrev[s] = 1;
        }

        long[] dp = new long[6];

        for(int i =1; i < n; i++) {
            for(int s =1; s <=5; s++) {
                dp[s] =0;
            }

            if(prices[i] > prices[i-1]) {
                long[] prefix = new long[6];
                prefix[0] =0;
                for(int s =1; s <=5; s++) {
                    prefix[s] = (prefix[s-1] + dpPrev[s]) % MOD;
                }
                for(int s=1; s <=5; s++) {
                    dp[s] = prefix[s-1];
                }
            }
            else if(prices[i] < prices[i-1]) {
                long[] suffix = new long[7];
                suffix[6] =0;
                for(int s =5; s >=1; s--) {
                    suffix[s] = (suffix[s+1] + dpPrev[s]) % MOD;
                }
                for(int s=1; s <=5; s++) {
                    dp[s] = suffix[s+1];
                }
            }
            else {
                long[] prefix = new long[6];
                prefix[0] =0;
                for(int s =1; s <=5; s++) {
                    prefix[s] = (prefix[s-1] + dpPrev[s]) % MOD;
                }
                for(int s=1; s <=5; s++) {
                    dp[s] = prefix[s];
                }
            }

            for(int s=1; s <=5; s++) {
                dpPrev[s] = dp[s] % MOD;
            }
        }

        long total =0;
        for(int s=1; s <=5; s++) {
            total = (total + dpPrev[s]) % MOD;
        }
        return (int) total;
    }


Amazon โœ…
๐Ÿ‘1
def solve(arr, n, num):
    if n == 0 or num == 0:
        return 0
    memo = {}
    def dp(i, remaining):

        if (i, remaining) in memo:
            return memo[(i, remaining)]
        if i >= n:
            return 0
        if remaining < arr[i]:
            return 0
    
        pick = arr[i] + dp(i + 2, remaining - arr[i])
        skip = dp(i + 1, remaining)
        memo[(i, remaining)] = max(pick, skip)
        return memo[(i, remaining)]
    return dp(0, num)


Samsung โœ…
๐Ÿ‘1