๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.59K 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
#include <vector>
#include <algorithm>

bool isPal(int x) {
    int orig = x, rev = 0;
    while (x > 0) {
        rev = rev * 10 + x % 10;
        x /= 10;
    }
    return orig == rev;
}
vector<int> solution(vector<int>& trans) {
    vector<int> pal;
    for (int t : trans) {
        if (isPal(t)) {
            pal.push_back(t);
        }
    }
    sort(pal.rbegin(), pal.rend());
    return pal;
}

Visa โœ…
from collections import deque
def solution(latencies, threshold):
    m = deque() 
    n = deque() 
    start = 0 
    max_len = 0
    for end in range(len(latencies)):
        while m and latencies[m[-1]] <= latencies[end]:
            m.pop()
        while n and latencies[n[-1]] >= latencies[end]:
            n.pop()
        m.append(end)
        n.append(end)
        while latencies[m[0]] - latencies[n[0]] > threshold:
            start += 1
            if m[0] < start:
                m.popleft()
            if n[0] < start:
                n.popleft()
        max_len = max(max_len, end - start + 1)
    return max_len


Visa โœ…
def findLocalMaximums(a):
    def is_local_maximum(b, c):
        d = a[b][c]
        if d == 0:
            return False
        r = d * 2 + 1
        h = d
        rs = max(0, b - h)
        rn = min(len(a) - 1, b + h)
        cs = max(0, c - h)
        cn = min(len(a[0]) - 1, c + h)
        for x in range(rs, rn + 1):
            for y in range(cs, cn + 1):
                if (x == b - h and (y == c - h or y == c + h)) or \
                   (x == b + h and (y == c - h or y == c + h)):
                    continue 
                if (x, y) != (b, c) and a[x][y] >= d:
                    return False
        return True

    result = []
    for b in range(len(a)):
        for c in range(len(a[0])):
            if is_local_maximum(b, c):
                result.append([b, c])
   
    return sorted(result)


Visa โœ…
๐Ÿ‘1
def retrievePasscodes(strips):
    sorted_strips = sorted([s.strip() for s in strips], key=lambda x: int(x[0], 36))
    characters = [s[1:] for s in sorted_strips]
    result = [''.join(row) for row in zip(*characters)]
    for line in result:
        print(line)


IBM โœ…
#include <iostream>
#include <cmath>
#include <algorithm>

int solution(int M, int N) {
    int total_area = 4 * N + M;

    int x = static_cast<int>(:sqrt(total_area));

    while (x > 0) {
        int needed_tiles = x * x;

        int max_2x2_tiles = (x / 2) * (x / 2);

        if (needed_tiles <= 4 * min(N, max_2x2_tiles) + M) {
            return x;
        }

        --x;
    }

    return 0;
}


Microsoft โœ…
Task 1
๐Ÿ‘1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

void addEdge(unordered_map<int, vector<pair<int, bool>>>& adj, int u, int v, bool direction) {
    adj[u].emplace_back(v, direction);
    adj[v].emplace_back(u, !direction);
}

int dfs(int node, unordered_map<int, vector<pair<int, bool>>>& adj, unordered_set<int>& visited) {
    visited.insert(node);
    int reorientCount = 0;

    for (const auto& [neighbor, direction] : adj[node]) {
        if (visited.find(neighbor) == visited.end()) {
            if (direction) {
                reorientCount++;
            }
            reorientCount += dfs(neighbor, adj, visited);
        }
    }

    return reorientCount;
}

int solution(vector<int>& A, vector<int>& B, int N) {
    unordered_map<int, vector<pair<int, bool>>> adj;
    unordered_set<int> visited;

    for (int i = 0; i < N; ++i) {
        addEdge(adj, A[i], B[i], true);
    }

    return dfs(0, adj, visited);
}

Microsoft โœ…
Task 2
๐Ÿคฎ3๐Ÿ‘2โค1
def minMoves(k1, k2, k3, eT, aT, mT):
    n = k1 + k2 + k3
    de = set(range(1, k1 + 1))
    da = set(range(k1 + 1, k1 + k2 + 1))
    dm = set(range(k1 + k2 + 1, n + 1))
   
    eW = [0] * (n + 1)
    aW = [0] * (n + 1)
    mW = [0] * (n + 1)
   
    for t in eT:
        if t not in de:
            eW[t] = 1
           
    for t in aT:
        if t not in da:
            aW[t] = 1
           
    for t in mT:
        if t not in dm:
            mW[t] = 1
           
    pE = [0] * (n + 1)
    pA = [0] * (n + 1)
    pM = [0] * (n + 1)
   
    for i in range(1, n + 1):
        pE[i] = pE[i - 1] + eW[i]
        pA[i] = pA[i - 1] + aW[i]
        pM[i] = pM[i - 1] + mW[i]
   
    minM = float('inf')
   
    for i in range(n + 1):
        movesEA = pE[i]
        movesAM = pA[n] - pA[i]
        movesME = pM[n]
       
        totalM = movesEA + movesAM
        minM = min(minM, totalM)
   
    return minM


Titan (FTE) โœ…
๐Ÿ‘2
def foodItems(i1, i2, i3, i4):
    a = sorted(i4)
    if a[-1] - a[0] > i1 - 1:
        return -1
    m, c = 1, a[0]
    for x in a[1:]:
        if x - c > i1 - 1:
            m += 1
            c = x
    return m


Shell (FTE) โœ…
๐Ÿคฎ1
๐Ÿ“ŒAmantya Technologies

Currently seeking a fresher C/C++ Developer to join our team in Gurgaon.

Hiring Process:
Candidates will need to complete a technical test and a technical interview at our Gurgaon office.

Please send your CV to pooja.jassy@amantyatech.com