๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
#include <vector>
#include <iostream>
using namespace std;
int solve(vector<vector<int>>& operations) {
    const int MAX_N = 100001;
    vector<int> diff(MAX_N + 1, 0);
    for (const auto& op : operations) {
        int l = op[0];
        int r = op[1];
        diff[l] += 1;
        if (r + 1 <= MAX_N) {
            diff[r + 1] -= 1;
        }
    }
    int sum = 0;
    int aa = 0;
    for (int i = 1; i <= MAX_N; ++i) {
        aa += diff[i];
        if (aa % 2 != 0) {
            sum += i;
        }
    }

    return sum;
}


Flipping Switches โœ…
๐Ÿ‘1
MOD = 10**9 + 7

def factorial(n, mod):
    result = 1
    for i in range(2, n + 1):
        result = (result * i) % mod
    return result

def mod_inv(a, p):
    return pow(a, p - 2, p)

def comb(n, k, mod):
    if k > n:
        return 0
    numerator = factorial(n, mod)
    denominator = (factorial(k, mod) * factorial(n - k, mod)) % mod
    return (numerator * mod_inv(denominator, mod)) % mod

def count_ways(N, C, V):
    if V > C:
        return 0
    total_ways = 0
    for i in range(V, C + 1):
        total_ways = (total_ways + comb(C, i, MOD)) % MOD
    return total_ways

N, C, V = map(int, input().split())
print(count_ways(N, C, V))
Hello Connections,

We are hiring for our Client

Position: Analyst - Decision Science

Experience: 0-6month

Location : Bangalore- WFO

Skills: SQL, Python ,R and Tableau

A bachelorโ€™s degree in Statistics or other quantitative disciplines such as Engineering, Applied Mathematics, etc from IIT and NIT.
Interested candidate can share their resume at aiman.bano@zyoin.com
Candidates from Bangalore location is preferred.
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <unordered_map>
#include <string>
string solve(const std::string &s) {
unordered_map<char, char> charValueMap = {
        {'a', '0'}, {'b', '0'}, {'c', '0'}, {'d', '0'}, {'e', '0'},
        {'f', '1'}, {'g', '1'}, {'h', '1'}, {'i', '1'}, {'j', '1'},
        {'k', '0'}, {'l', '0'}, {'m', '0'}, {'n', '0'}, {'o', '0'},
        {'p', '1'}, {'q', '1'}, {'r', '1'}, {'s', '1'}, {'t', '1'},
        {'u', '0'}, {'v', '0'}, {'w', '0'}, {'x', '0'}, {'y', '0'},
        {'z', '1'}
    };

    std::string binaryString;
    for (char ch : s) {
        binaryString += charValueMap[ch];
    }

    return binaryString;
}

int main() {
   string inputString;
getline(std::cin, inputString);

   string result = solve(inputString);
   
  cout << result << std::endl;

    return 0;
}
.

TEXAS 2
๐Ÿ‘1๐Ÿ”ฅ1
def findParent(processNumber):
    if processNumber == 1:
        return None

    left, right = 1, processNumber

    while left < right:
        mid = (left + right) // 2
        children_up_to_mid = mid * (mid + 1) // 2
       
        if children_up_to_mid < processNumber:
            left = mid + 1
        else:
            right = mid

    parent = left
    children_up_to_parent = parent * (parent + 1) // 2

    return parent if children_up_to_parent >= processNumber else parent - 1


Process Tree โœ…
๐Ÿ‘1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000;
vector<int> tree[MAXN];
vector<int> prefixSum;
vector<int> cost;
vector<int> parent;
int N, K;
void dfs(int node, int par, int currentSum) {
    prefixSum[node] = currentSum + cost[node];
    parent[node] = par;
    for (int child : tree[node]) {
        if (child != par) {
            dfs(child, node, prefixSum[node]);
        }
    }
}
int solve(int N, int K, vector<int>& A, vector<vector<int>>& edges) {
    cost = A;
    prefixSum.assign(N, 0);
    parent.assign(N, -1);
   
    for (int i = 0; i < N; ++i) {
        tree[i].clear();
    }
   
    for (auto& edge : edges) {
        int u = edge[0] - 1;
        int v = edge[1] - 1;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }

    dfs(0, -1, 0);
    int maxCandies = 0;
    for (int i = 0; i < N; ++i) {
        int remainingMoney = K;
        int candies = 0;
        for (int j = i; j != -1; j = parent[j]) {
            if (remainingMoney >= cost[j]) {
                remainingMoney -= cost[j];
                candies++;
            } else {
                break;
            }
        }
        maxCandies = max(maxCandies, candies);
    }

    return maxCandies;
}


Zepto โœ…
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
using namespace std;
int solve(int N, int K, const vector<int>& houses) {
    unordered_map<int, int> houseIndex;
    for (int i = 0; i < houses.size(); ++i) {
        houseIndex[houses[i] - 1] = i + 1;
    }

    priority_queue<int> pq;
    for (int i = 0; i < K; ++i) {
        pq.push(houseIndex[i]);
    }

    int ans = pq.top();
    for (int i = 1; i + K - 1 < N; ++i) {
        pq.push(houseIndex[i + K - 1]);
        while (!pq.empty() && pq.top() > houseIndex[i + K - 1]) {
            pq.pop();
        }
        ans = min(ans, pq.top());
    }

    return ans;
}

Happy neighborhoodโœ…
int findTiles(int M, int N)
{
    int x = sqrt(4 * N + M);
    if (x % 2 == 0)
        return x;
    else {
        int inter = ((x - 1) * (x - 1)) / 4;
        if (4 * min(inter, N) + M >= x * x)
            return x;
        else
            return x - 1;
    }
}

Microsoft
Task 2โœ…
๐Ÿ‘1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define sz(c) c.size()
ll solve()

{

    ll n, m, i, j;
    ll k;
    ll l, r;

    string s;
    cin >> s;
    n = sz(s);

    ll dp[n][5];
    memset(dp, 0, sizeof(dp));

    if (s[0] == 'a')
        dp[0][0] = 1;

    for (int i = 1; i < n; i++)

    {

        if (s[i] == 'a')

        {

            dp[i][0] = 1 + dp[i - 1][0];
        }

        else

            dp[i][0] = dp[i - 1][0];

        if (s[i] == 'e')

        {

            if (dp[i - 1][1] != 0)

                dp[i][1] = 1 + dp[i - 1][1];

            if (dp[i - 1][0] != 0)

                dp[i][1] = max(dp[i][1], 1 + dp[i - 1][0]);
        }

        else

            dp[i][1] = dp[i - 1][1];

        if (s[i] == 'i')

        {

            if (dp[i - 1][2] != 0)

                dp[i][2] = 1 + dp[i - 1][2];

            if (dp[i - 1][1] != 0)

                dp[i][2] = max(dp[i][2], 1 + dp[i - 1][1]);
        }

        else

            dp[i][2] = dp[i - 1][2];

        if (s[i] == 'o')

        {

            if (dp[i - 1][3] != 0)

                dp[i][3] = 1 + dp[i - 1][3];

            if (dp[i - 1][2] != 0)

                dp[i][3] = max(dp[i][3], 1 + dp[i - 1][2]);
        }

        else

            dp[i][3] = dp[i - 1][3];

        if (s[i] == 'u')

        {

            if (dp[i - 1][4] != 0)

                dp[i][4] = 1 + dp[i - 1][4];

            if (dp[i - 1][3] != 0)

                dp[i][4] = max(dp[i][4], 1 + dp[i - 1][3]);
        }

        else

            dp[i][4] = dp[i - 1][4];
    }

    cout << dp[n - 1][4];

    return 0;
}

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll t;

    t = 1;

    // cin>>t;

    while (t--)

    {

        solve();
    }

    return 0;
}


//longest Vowel subsequence with ordered vowel โœ…
๐Ÿ‘1
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
vector<int> smallestLexicographicalSubsequence(vector<int>& hubs, int k) {
    vector<int> result;
    stack<int> st;
    int n = hubs.size();

    for (int i = 0; i < n; ++i) {
        while (!st.empty() && st.top() > hubs[i] && st.size() + (n - i) > k) {
            st.pop();
        }
        if (st.size() < k) {
            st.push(hubs[i]);
        }
    }
        while (!st.empty()) {
        result.insert(result.begin(), st.top());
        st.pop();
    }
   
    return result;
}