๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.55K photos
3 videos
95 files
9.64K 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 <bits/stdc++.h>
using namespace std;

bool check(int K, const vector<int> &B, int C)
{
    int A = B.size();
    vector<int> S(A);
    for (int i = 0; i < A; ++i)
    {
        S[i] = (B[i] >= K) ? 1 : -1;
    }
    vector<int> P(A + 1, 0);
    for (int i = 1; i <= A; ++i)
    {
        P[i] = P[i - 1] + S[i - 1];
    }
    int min_prefix = 0;
    for (int i = C; i <= A; ++i)
    {
        min_prefix = min(min_prefix, P[i - C]);
        if (P[i] - min_prefix > 0)
        {
            return true;
        }
    }
    return false;
}

int solve(int A, const vector<int> &B, int C)
{
    int Left = 1, Right = A;
    int answer = A; 
    while (Left <= Right)
    {
        int Mid = (Left + Right) / 2;
        if (check(Mid, B, C))
        {
            answer = A - (Mid - 1);
            Left = Mid + 1;
        }
        else
        {
            Right = Mid - 1;
        }
    }
    if (answer > A)
    {
        answer = A;
    }
    return answer;
}

int main()
{
    int A = 5;
    cin >> A;

    vector<int> B(A) ;
    for(auto &i:B) cin>>i;
    int C = 3;
    cin>>C;
    cout << solve(A, B, C) << endl;

    return 0;
}

Trilogy
Book Collector โœ…
int solution(vector<int> arr, vector<vector<int>> mat) {
int totalUpdates = 0;
    int n = arr.size();
   
    for (const auto &query : mat) {
        int X = query[0] - 1;
        int Y = query[1];
        int Z = query[2];

        int bitMask = (1 << (Y - 1));

        int endIndex = X;
        while (endIndex < n && (arr[endIndex] & bitMask)) {
            endIndex++;
        }
       
        int sizeToUpdate = endIndex - X;
       
        if (sizeToUpdate > 0) {
            for (int i = X; i < endIndex; ++i) {
                arr[i] ^= Z;
            }
            totalUpdates += sizeToUpdate;
        }
    }
   
    return totalUpdates;
}

Xor(Trilogy)โœ…
#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9 + 7;
typedef vector<vector<long long>> Matrix;
Matrix multiply(const Matrix &A, const Matrix &B) {
    int n = A.size();
    Matrix result(n, vector<long long>(n, 0));
    for (int i = 0; i < n; ++i) {
        for (int k = 0; k < n; ++k) {
            if (A[i][k]) {
                for (int j = 0; j < n; ++j) {
                    result[i][j] = (result[i][j] + A[i][k] * B[k][j]) % MOD;
                }
            }
        }
    }
    return result;
}

Matrix matrix_power(Matrix base, long long exponent) {
    int n = base.size();
    Matrix result(n, vector<long long>(n, 0));
    for (int i = 0; i < n; ++i)
        result[i][i] = 1;

    while (exponent > 0) {
        if (exponent % 2 == 1)
            result = multiply(result, base);
        base = multiply(base, base);
        exponent /= 1LL << 1;
    }
    return result;
}

int solve(long long A, int B, int C) {
    if (A == 0)
        return 0;
    vector<long long> S0(B, 0);
    S0[0] = C % MOD;
    Matrix M(B, vector<long long>(B, 0));

    for (int k = 0; k < B; ++k) {
        if (k + 1 < B) {
            M[k][k + 1] = 1;
        }
        M[k][0] = (C - 1) % MOD;
    }
    Matrix M_power = matrix_power(M, A - 1);
    vector<long long> S(B, 0);
    for (int i = 0; i < B; ++i) {
        for (int j = 0; j < B; ++j) {
            S[i] = (S[i] + S0[j] * M_power[j][i]) % MOD;
        }
    }
    long long total = 0;
    for (int i = 0; i < B; ++i) {
        total = (total + S[i]) % MOD;
    }

    return (int)total;
}

Valid Array (Trilogy) โœ…
Don't apply for jobs at Workday and
Prefer applying for jobs at platforms like greenhouse, LinkedIn, lever, indeed or Glassdoor.

Your job application process should scale easily and one application shouldn't take more than 2 min to apply.

Workday sucks at scalability, Better to ignore it.๐Ÿ™Œ
๐Ÿš€ Exciting Internship Opportunity at T-Systems! ๐Ÿš€
Are you a 2024 graduate looking to kickstart your career with hands-on industry experience? ๐ŸŒŸ T-Systems is hiring interns for various exciting roles.
โœ… Who can apply?
Graduates with 60% or more throughout their 10th, 12th, Graduation/Post Graduation.
Degree in BCS, BSc, MSc, MCA, BE, BTech, or MBA.
Passout year: 2024 only

๐Ÿ™ Locations: Pune or Bangalore
๐Ÿ•’ Internship Duration: 3-6 months

Apply here: https://smrtr.io/nvkHg
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int N = sc.nextInt();
        int[] commands = new int[N];
        for (int i = 0; i < N; i++) {
            commands[i] = sc.nextInt();
        }
        int[] dx = {0, 1, 0, -1}; 
        int[] dy = {1, 0, -1, 0};
        int x = 0, y = 0; 
        int dir = 0; 
        int totalX = 0, totalY = 0;
        for (int i = 0; i < N; i++) {
            x += commands[i] * dx[dir];
            y += commands[i] * dy[dir];
            dir = (dir + 1) % 4;
        }
        totalX = x;
        totalY = y;
        int finalX = totalX * K;
        int finalY = totalY * K;
        System.out.println(Math.abs(finalX) + Math.abs(finalY));

        sc.close();
    }
}


Autonomous Car AIโœ…
Intuit
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
                int N = sc.nextInt();
       
        char[] colors = {'R', 'O', 'Y', 'G', 'B', 'I', 'V'};
                Set<Character> usedColors = new HashSet<>();
                for (int i = 0; i < N; i++) {
            int canNumber = sc.nextInt();
            char color = colors[(canNumber - 1) % 7];
            usedColors.add(color);
        }
    System.out.println(usedColors.size());
       
        sc.close();
    }
}


Colors of the Rainbow โœ…
Intuit