๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
int webdev(int numProject,vector<int>projectId,vector<int>bid){
    vector<int>ans(numProject,INT_MAX);
    for(int i=0; i<projectId.size(); i++){
        ans[projectId[i]]=min(ans[projectId[i]], bid[i]);
    }
    int sum=0;
    for(auto x: ans){
        if(x!=INT_MAX)
        sum+=x;
        else
        return -1;
    }
๐Ÿ‘1
def solution(number):
    left = 0
    while left < len(number):
        right = left
        candidateNumb = number[left]
        while right < len(number) and number[right] == candidateNumb:
            right += 1
        if right - 1 > left:
            newNumber = number[left:right]
            newNumberList = [int(n) for n in newNumber]
            newNumberSum = sum(newNumberList)
            number = number[:left] + str(newNumberSum) + number[right:]
            if left > 0:
                left -= 1
        else:
            left += 1
    return number

Visa โœ…
int cardsDeck(int N, vector<int>& A) {
    vector<pair<int, int>> v(N);
    for (int i = 0; i < N; i++) v[i] = {A[i], i};
    sort(v.rbegin(), v.rend());
   
    vector<bool> used(N);
    int res = 0, cur = 0;
    for (auto [val, idx] : v) {
        if (!used[idx]) {
            used[idx] = true;
            res = max(res, ++cur);
        }
        if (cur + (N - idx - 1) <= res) break;
    }
    return res;
}

Cards Deck
Grow(FTE) โœ…
def findMinimumIdleness(s, k):
    def ci(t):
        m, c = 0, 1
        for i in range(1, len(t)):
            if t[i] == t[i-1]:
                c += 1
            else:
                m = max(m, c)
                c = 1
        return max(m, c)

    def dfs(t, r):
        if r == 0:
            return ci(t)
        m = ci(t)
        for i in range(len(t)):
            m = min(m, dfs(t[:i] + ('b' if t[i] == 'a' else 'a') + t[i+1:], r - 1))
        return m

    return dfs(s, k)


LinkedIn(FTE) โœ…
vector<int> findCompletePrefixes(vector<string> names, vector<string> queries){
    vector<int> res;
   
    for(string q : queries){
        int count = 0;
        for(string s : names){
            if(s.size() >= q.size() + 1 && s.compare(0, q.size(), q) == 0){
                count++;
            }
        }
        res.push_back(count);
    }
    return res;
}

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

void f(vector<int> &A, vector<int> &B) {
    vector<int> c(B.size(), -1);
    vector<int> preSum(A.size(), 0);
   
    preSum[0] = A[0];
    for(int i = 1; i < A.size(); i++) {
        preSum[i] = preSum[i-1] + A[i];
    }

    for(int i = 0; i < B.size(); i++) {
        int val = B[i];
        int x = val / preSum[A.size() - 1];
        int y = val % preSum[A.size() - 1];

        if (y == 0) {
            c[i] = x * A.size();
            continue;
        }

        int cnt = 0;
        for(int j = 0; j < A.size(); j++) {
            if (A[j] >= y) {
                cnt = j + 1;
                break;
            }
        }

        int res = (x * A.size()) + cnt;
        if (res > 0) {
            c[i] = res;
        }
    }

    for(auto x : c) {
        cout << x << " ";
    }
}

int main() {
    vector<int> A{7, -15, 19, -15, -11, 17, 5};
    vector<int> B{6, 30, -17, 12};

    f(A, B);
    return 0;
}

Read Books nckd โœ…
WITH ranked_stocks AS (
  SELECT
    s.id,
    s.name,
    mc.closing_date,
    mc.closing_price,
    LAG(mc.closing_price) OVER (PARTITION BY s.id ORDER BY mc.closing_date) AS prev_closing_price,
    ROW_NUMBER() OVER (PARTITION BY s.id ORDER BY mc.closing_date) AS row_num
  FROM stocks s
  JOIN monthly_closing mc ON s.id = mc.stock_id
)
SELECT
  id,
  name,
  closing_date,
  closing_price,
  CASE
    WHEN row_num = 1 THEN 0.00
    ELSE ROUND(prev_closing_price - closing_price, 2)
  END AS price_diff
FROM ranked_stocks
ORDER BY id, closing_date


Meesho (BA) โœ…
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    vector<int> candies(10);
    for (int i = 0; i < 10; ++i) {
        cin >> candies[i];
    }

    int cumulative_sum = 0;
    int best_sum = 0;

    for (int i = 0; i < 10; ++i) {
        cumulative_sum += candies[i];

        if (abs(100 - cumulative_sum) < abs(100 - best_sum)) {
            best_sum = cumulative_sum;
        }
        else if (abs(100 - cumulative_sum) == abs(100 - best_sum) && cumulative_sum < best_sum) {
            best_sum = cumulative_sum;
        }

        if (cumulative_sum >= 100) {
            break;
        }
    }

    cout << best_sum << endl;

    return 0;
}


Deloitte โœ…
def maximumOccurringCharacter(text):
    from collections import Counter
    cnt = Counter(c for c in text if c.isalnum())
    return max(cnt, key=lambda x: (cnt[x], -text.index(x)))


Amdocs โœ…
#include <iostream>
#include <string>
#include <unordered_set>

using namespace std;

int countPunctuations(const string& str) {
    unordered_set<char> punctuations = {'(', ')', '[', ']', ':', '_', ';', '\'', '!', '?', '"', '-', '{', '}', '/', '\\', '.'};
    int count = 0;
        for (char ch : str) {
        if (punctuations.find(ch) != punctuations.end()) {
            count++;
        }
    }
   
    return count;
}

int main() {
    string input;

    getline(cin, input);
        int punctuationCount = countPunctuations(input);
   
    cout <<punctuationCount << endl;
   
    return 0;
}


Deloitte โœ