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

class DSU {
public:
    std::vector<int> parent, size;

    DSU(int n) {
        parent.resize(n + 1);
        size.resize(n + 1, 1);
        for (int i = 1; i <= n; i++) {
            parent[i] = i;
        }
    }

    int find(int x) {
        if (x == parent[x]) {
            return x;
        }
        return parent[x] = find(parent[x]);
    }

    void merge(int x, int y) {
        int rootX = find(x);
        int rootY = find(y);
        if (rootX != rootY) {
            if (size[rootX] < size[rootY]) {
                std::swap(rootX, rootY);
            }
            parent[rootY] = rootX;
            size[rootX] += size[rootY];
        }
    }
};

vector<int> getTheGroups(int n, std::vector<std::string>& queryType, std::vector<int>& student1, std::vector<int>& student2) {
    DSU dsu(n + 1);
    std::vector<int> ans;

    for (int i = 0; i < n; i++) {
        if (queryType[i] == "Friend") {
            dsu.merge(student1[i], student2[i]);
        } else {
            int root1 = dsu.find(student1[i]);
            int root2 = dsu.find(student2[i]);
            ans.push_back(dsu.size[root1] + dsu.size[root2] - (root1 == root2 ? 1 : 0));
        }
    }

    return ans;
}

Get the groupsโœ…
โค1๐Ÿ‘1
def solution(n, t, edges):
    graph = [[] for _ in range(n)]
    for u, v in edges:
        graph[u].append(v)
        graph[v].append(u)
   
    def dfs(node, parent):
        size, time_sum = 1, 0
        for child in graph[node]:
            if child != parent:
                c_size, c_time = dfs(child, node)
                size += c_size
                time_sum += c_time + t[child] * c_size
        return size, time_sum
   
    total_time = sum(t)
    expected_times = [0] * n
   
    def calculate_expected(node, parent, parent_contrib):
        size, time_sum = dfs(node, parent)
        expected_times[node] = t[node] + (time_sum + parent_contrib) / (n - 1)
        for child in graph[node]:
            if child != parent:
                child_contrib = parent_contrib + (total_time - time_sum - t[child]) * (n - size)
                calculate_expected(child, node, child_contrib / (n - 1))
   
    calculate_expected(0, -1, 0)
    return min(range(n), key=lambda i: expected_times[i])
#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