๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.62K subscribers
5.59K photos
3 videos
95 files
10.2K 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;

unsigned int single_digit_sum(int num) {
    while (num >= 10) {
        int sum = 0;
        while (num > 0) {
            sum += num % 10;
            num /= 10;
        }
        num = sum;
    }
    return num;
}

unsigned int quotient(int** a, int n, int p, int q) {
    unsigned int diagonal_sum = 0;
    for (int i = 0; i < n; ++i) {
        diagonal_sum += a[i][i];
    }
   
    unsigned int single_digit = single_digit_sum(a[p][q]);
   
    return diagonal_sum / single_digit;
}

int main() {
    int i, j, p, q;
    int n;
    cin >> n;
   
    int** a = new int*[n];
    for (i = 0; i < n; ++i) {
        a[i] = new int[n];
    }
   
    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            cin >> a[i][j];
        }
    }
   
    cin >> p >> q;
   
    cout << quotient(a, n, p, q);
   
    for (i = 0; i < n; ++i) {
        delete[] a[i];
    }
    delete[] a;
   
    return 0;
}

Principal FTE โœ…
๐Ÿ‘1
int Max (int N, int K, vector<int> arr) {
   vector<int> b(N + 1, 0);
    vector<int> c;
    int cnt = 0;
    for (int i = 1; i <= N; ++i) {
        if (arr[i - 1] % 2 == 1) {
            b[i] = 1;
        } else {
            b[i] = -1;
        }
    }
    for (int i = 1; i <= N; ++i) {
        b[i] += b[i - 1];
    }
    for (int i = 1; i < N; ++i) {
        if (b[i] == 0) {
            c.push_back(abs(arr[i] - arr[i - 1]));
        }
    }
    sort(c.begin(), c.end());
    int pt = 0, cost = 0;

    while (pt < c.size() && cost + c[pt] <= K) {
        cost += c[pt];
        ++pt;
    }

    return pt;
}

max separations
โœ…
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1000000;
vector<long long> dp(MAXN + 1, 0);
void precompute() {
    dp[1] = 1;
    for (int i = 1; i <= MAXN; i++) {
        for (int j = 2 * i; j <= MAXN; j += i) {
            dp[j] += dp[i];
        }
    }
}

class Precompute {
public:
    Precompute() {
        precompute();
    }
};
Precompute pre;

long long solve(int N) {
    return dp[N];
}


Islands
BT Group โœ…
#include <iostream>
#include <vector>
using namespace std;
long long sumDifferentParity(int N, const vector<int>& A) {
    long long sum = 0;
    for (int i = 1; i <= N; ++i) {
        int value = A[i - 1];
        if ((i % 2) != (value % 2)) {
            sum += value;
        }
    }

    return sum;
}

correct pair sumโœ…
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
long long findMaxRequests(int N, vector<int>& A, vector<int>& L, vector<int>& R) {
    map<int, long long> events;
    for (int i = 0; i < N; i++) {
        events[L[i]] += A[i];     
        events[R[i]] -= A[i];      
    }
    long long c = 0;
    long long m = 0;
    for (auto& event : events) {
        c += event.second;
        m = max(m, c);
    }
    return m;
}


Server Capability โœ…
https://www.linkedin.com/posts/bhavana-bhavana-5b024a188_greeting-from-quess-corp-we-are-hiring-for-activity-7238787314640900096-xfph?utm_source=share&utm_medium=member_desktop

Greeting from Quess corp
We are hiring for one of our reputed client for Desktop management

Fresher only 2022, 2023 and 2024 batch
WFO /WFH โ€“ WFO
Work Timings โ€“ 6:30 PM โ€“ 4 AM IST Both the way cab will be provided
Work Location โ€“ Bangalore
CTC - 21900 Monthly

Job Description โ€“ Desktop Support Management.
Summary: As an Application Support Engineer, you will be responsible for identifying and solving issues within multiple components of critical business systems. Your typical day will involve providing support for Microsoft Windows Desktop Management and ensuring smooth functioning of the systems
๐Ÿ‘1
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int solution(const vector<int>& A, const vector<int>& B) {
    int N = A.size();

     vector<vector<int>> dp(2, vector<int>(N));
    dp[0][0] = A[0];
    dp[1][0] = max(A[0], B[0]);

    for (int j = 1; j < N; ++j) {
        dp[0][j] = max(dp[0][j - 1], A[j]);
        dp[1][j] = min(max(dp[0][j], B[j]), max(dp[1][j - 1], B[j]));
    }

    return dp[1][N - 1];
}

Amex โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <set>
#include <iomanip>
#include <sstream>
using namespace std;
bool isInteresting(const string& timeStr) {
    set<char> uniqueDigits;
        for (char ch : timeStr) {
        if (ch != ':') {
            uniqueDigits.insert(ch);
        }
    }
        return uniqueDigits.size() <= 2;
}
void incrementTime(int& hh, int& mm, int& ss) {
    ss++;
    if (ss == 60) {
        ss = 0;
        mm++;
    }
    if (mm == 60) {
        mm = 0;
        hh++;
    }
    if (hh == 24) {
        hh = 0;
    }
}
string timeToString(int hh, int mm, int ss) {
    ostringstream oss;
    oss << setw(2) << setfill('0') << hh << ":"
        << setw(2) << setfill('0') << mm << ":"
        << setw(2) << setfill('0') << ss;
    return oss.str();
}
int solve(const string& S, const string& T) {
    int shh = stoi(S.substr(0, 2));
    int smm = stoi(S.substr(3, 2));
    int sss = stoi(S.substr(6, 2));
    int ehh = stoi(T.substr(0, 2));
    int emm = stoi(T.substr(3, 2));
    int ess = stoi(T.substr(6, 2));
    int interestingCount = 0;
        while (true) {
        string currentTime = timeToString(shh, smm, sss);
                if (isInteresting(currentTime)) {
            interestingCount++;
        }
                if (shh == ehh && smm == emm && sss == ess) {
            break;
        }
                incrementTime(shh, smm, sss);
    }
   
    return interestingCount;
}


Amex โœ…
long long solve(int n, int** A) {
    vector<pair<int, int>> vp;
    vp.push_back({-1, 0});

    for (int i = 0; i < n; i += 1) {
        vp.push_back({A[i][1], A[i][2]});
    }

    sort(vp.begin(), vp.end());

    auto check = [&] (int mid) {
        long long dishes = 0;

        for (int i = 1; i <= n; i += 1) {
            dishes += static_cast<long long>(vp[i].first - vp[i - 1].first) * mid;
            if (vp[i].second > dishes)
                return false;
            else
                dishes -= vp[i].second;
        }

        return true;
    };

    int l = 0, r = 1e9;

    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (!check(mid))
            l = mid;
        else
            r = mid;
    }

    return r;
}

Chef and ordering โœ…
from math import ceil

def getMinDifference(n, e1, t1, e2, c):
    res = float('inf')
    
    energy_list = [e1 * i for i in range(n + 1)]

    for i in range(n + 1):
        lift = i * t1
        energy = energy_list[i]

        if energy < (n - i) * e2:
            continue

        steps = 0
        
        steps_list = [ceil(c / energy) for _ in range(n - i)]
        energy -= sum(steps_list) * e2

        res = min(res, abs(lift - sum(steps_list)))

    return res

Meesho โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <algorithm> 
#include <cstring>
using namespace std;

const int MOD = 1e9 + 7;
int dp[20][200][200][2];
vector<int> getDigits(int x) {
    vector<int> digits;
    while (x > 0) {
        digits.push_back(x % 10);
        x /= 10;
    }
    reverse(digits.begin(), digits.end());
    return digits;
}
int digitDP(int pos, int sumEven, int sumOdd, int tight, const vector<int>& digits) {
    if (pos == digits.size()) {
        return (sumEven % 2 == sumOdd % 2) ? 1 : 0;
    }
    if (dp[pos][sumEven][sumOdd][tight] != -1) {
        return dp[pos][sumEven][sumOdd][tight];
    }

    int limit = tight ? digits[pos] : 9;
    int res = 0;
    for (int digit = 0; digit <= limit; ++digit) {
        int newTight = (tight && (digit == digits[pos]));
        if (pos % 2 == 0) {
            res = (res + digitDP(pos + 1, sumEven + digit, sumOdd, newTight, digits)) % MOD;
        } else {
            res = (res + digitDP(pos + 1, sumEven, sumOdd + digit, newTight, digits)) % MOD;
        }
    }
    return dp[pos][sumEven][sumOdd][tight] = res;
}
int countNumbersWithSameParityOfSums(int x) {
    if (x <= 0) return 0;
   
    vector<int> digits = getDigits(x);
    memset(dp, -1, sizeof(dp));
    return digitDP(0, 0, 0, 1, digits);
}
int findParityCountInRange(int a, int b) {
    int result_b = countNumbersWithSameParityOfSums(b);
    int result_a = countNumbersWithSameParityOfSums(a);
        return (result_b - result_a + MOD) % MOD;
}


Meesho โœ…
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
const int MOD = 1e9 + 7;
int getExpressionSums(string num) {
    int n = num.size();
    long long res = 0;
    for (int mask = 0; mask < (1 << (n - 1)); ++mask) {
        string s = ""; 
        s += num[0];
        for (int i = 0; i < n - 1; ++i) {
            if (mask & (1 << i)) {
                s += '+'; 
            }
            s += num[i + 1]; 
        }
        long long current_sum = 0;
        string temp = "";
        for (char c : s) {
            if (c == '+') {
                current_sum += stoll(temp);
                temp = "";
            } else {
                temp += c; 
            }
        }
        current_sum += stoll(temp); 

        res = (res + current_sum) % MOD; 
    }

    return res;
}


Meesho โœ