๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.61K 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
def ok(mid, N, M):
    count = 0
    for i in range(1, N + 1):
        count += min(M, mid // i)
    return count
def solve(N, M, K):
    low, high = 1, N * M
    while low < high:
        mid = (low + high) // 2
        if ok(mid, N, M) < K:
            low = mid + 1
        else:
            high = mid
    return low
N, M, K = map(int, input().split())
print(solve(N, M, K))

A lot to merge โœ…
Media. Net
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1000000007;

struct node {
    int val;
    int lazy;
    node *left;
    node *right;

    node() {
        left = nullptr;
        right = nullptr;
        lazy = 0;
        val = 0;
    }
};

void build(node *&root, int s, int e) {
    root = new node();
    if (s == e) {
        root->val = 0;
    } else {
        int mid = (s + e) / 2;
        build(root->left, s, mid);
        build(root->right, mid + 1, e);
        root->val = root->left->val + root->right->val;
    }
}

void applyLazy(node* root, int s, int e) {
    if (root->lazy) {
        root->val = (e - s + 1) - root->val;
        if (s != e) {
            if (!root->left) root->left = new node();
            if (!root->right) root->right = new node();
            root->left->lazy ^= 1;
            root->right->lazy ^= 1;
        }
        root->lazy = 0;
    }
}

void update_range(node *root, int s, int e, int l, int r) {
    applyLazy(root, s, e);
    if (s > r || e < l) return;
    if (s >= l && e <= r) {
        root->lazy ^= 1;
        applyLazy(root, s, e);
        return;
    }
    int mid = (s + e) / 2;
    update_range(root->left, s, mid, l, r);
    update_range(root->right, mid + 1, e, l, r);
    root->val = root->left->val + root->right->val;
}

int query(node *root, int s, int e, int l, int r) {
    applyLazy(root, s, e);
    if (s > r || e < l) return 0;
    if (s >= l && e <= r) {
        return root->val;
    }
    int mid = (s + e) / 2;
    int leftQuery = query(root->left, s, mid, l, r);
    int rightQuery = query(root->right, mid + 1, e, l, r);
    return leftQuery + rightQuery;
}

int solve(int N, vector<vector<int>>& B) {
    node* root = nullptr;
    build(root, 0, N - 1);
   
    int sumQueries = 0;
    for (const auto& op : B) {
        int type = op[0];
        int l = op[1] - 1;
        int r = op[2] - 1;

        if (type == 0) {
            update_range(root, 0, N - 1, l, r);
        } else {
            sumQueries += query(root, 0, N - 1, l, r);
            sumQueries %= MOD;
        }
    }
    return sumQueries;
}

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> B(Q, vector<int>(3));
   
    for (int i = 0; i < Q; ++i) {
        cin >> B[i][0] >> B[i][1] >> B[i][2];
    }

    int result = solve(N, B);
    cout << result << endl;

    return 0;
}


Mask updates
Media. Netโœ…
๐Ÿ‘1
#include <bits/stdc++.h>
using namespace std;
void solve() {
    int T;
    cin >> T;
    while (T--) {
        int n, x;
        cin >> n >> x;
        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        vector<int> remainderCount(x, 0);
        for (int i = 0; i < n; i++) {
            remainderCount[a[i] % x]++;
        }
        int pairs = 0;
        pairs += remainderCount[0] / 2;
        for (int r = 1; r <= x / 2; r++) {
            if (r == x - r) {
                pairs += remainderCount[r] / 2;
            } else {
                int minCount = min(remainderCount[r], remainderCount[x - r]);
                pairs += minCount;
                remainderCount[r] -= minCount;
                remainderCount[x - r] -= minCount;
            }
        }
        cout << pairs * 2 << endl;
    }
}

int main() {
    solve();
    return 0;
}


christmas celebration โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
class Shop:
    def __init__(self):
        self.items = {}
    def create(self, X, Y):
        if X in self.items and self.items[X] > 0:
            return False
        else:
            self.items[X] = Y
            return True
    def place_order(self, X, Y, Z):
        if Y not in self.items or self.items[Y] < Z:
            return False
        else:
            self.items[Y] -= Z
            return True
   
    def balance(self):
        return sum(self.items.values())
def process_queries(queries):
    shop = Shop()
    result = []
    for query in queries:
        parts = query.split()
        command = parts[0]
        if command == "Create":
            X = int(parts[1])
            Y = int(parts[2])
            if shop.create(X, Y):
                result.append("Item Created successfully!")
            else:
                result.append("Couldn't create item!")
        elif command == "PlaceOrder":
            X = int(parts[1])
            Y = int(parts[2])
            Z = int(parts[3])
            if shop.place_order(X, Y, Z):
                result.append("Order placed successfully!")
            else:
                result.append("Couldn't place order!")
        elif command == "Balance":
            result.append(f"Total no of items in the shop is {shop.balance()}")
    return result


Shop inventory โœ…
๐Ÿ‘1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll solve(ll n, ll m, vector<vector<string>>& c) {
    vector<vector<ll>> g1(n), g2(n);
    vector<ll> d1(n, 0), d2(n, 0);
    for (const auto& t : c) {
    if (t[0] == "x") {
    ll a = stoll(t[1]) - 1;
    ll b = stoll(t[2]) - 1;
    g1[a].push_back(b);
    d1[b]++;
    } else if (t[0] == "y") {
    ll a = stoll(t[1]) - 1;
    ll b = stoll(t[2]) - 1;
    g2[a].push_back(b);
    d2[b]++;
        }
    }

    auto ts = [&](vector<vector<ll>>& g, vector<ll>& d) -> vector<ll> {
    queue<ll> q;
    for (ll i = 0; i < n; i++) {
    if (d[i] == 0) q.push(i);
    }
    vector<ll> o;
    while (!q.empty()) {
    ll u = q.front();
    q.pop();
    o.push_back(u);
    for (ll v : g[u]) {
    d[v]--;
    if (d[v] == 0) q.push(v);
        }
        }
    return o.size() == n ? o : vector<ll>();
    };

    vector<ll> o1 = ts(g1, d1);
    vector<ll> o2 = ts(g2, d2);
    if (o1.empty() || o2.empty()) return -1;
    vector<ll> r(n, 0), cols(n, 0);
    for (ll i = 0; i < n; i++) {
    for (ll v : g1[o1[i]]) {
    r[v] = max(r[v], r[o1[i]] + 1);
    }
    }
    for (ll i = 0; i < n; i++) {
    for (ll v : g2[o2[i]]) {
    cols[v] = max(cols[v], cols[o2[i]] + 1);
        }
    }
    ll max_r = *max_element(r.begin(), r.end()) + 1;
    ll max_cols = *max_element(cols.begin(), cols.end()) + 1;
    return max_r + max_cols;
}
int main() {
    ll n, m;
    cin >> n >> m;
    vector<vector<string>> c(m, vector<string>(3));
    for (ll i = 0; i < m; i++) {
        cin >> c[i][0] >> c[i][1] >> c[i][2];
    }
    cout << solve(n, m, c) << endl;
    return 0;
}


Stay inside Circle โœ…
๐Ÿ‘1
๐Ÿ“ŒAminurmus Technology is hiring

Multiple Roles:
- SDE ( Intern/Fulltime)
- Reactjs Developer ( Intern/Fulltime)
- Dot net Developer (Intern/ Fulltime)
- Mern Stack Developer (Intern/Fulltime)
- Figma Developer Intern
- Fullstack Developer (Intern/Fulltime)
- Data Analysis
- Android Developer

Remote Opportunity

Batch: First year to Final Year

๐Ÿ’ปApply: https://aminurmus.com/career

Use Referral Mail Id:
rupam.bernwal@aminurmus.com
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll maxcoins(ll A[], ll siz) {
    ll nums[siz + 2];
    ll n = 1;
    for (ll i = 0; i < siz; i++) {
    if (A[i] > 0) {
    nums[n] = A[i];
    n++;
    }
    }
    nums[0] = nums[n] = 1;
    n++;
    ll dp[n][n] = {};
    for (ll j = 2; j < n; j++) {
    for (ll left = 0; left < n - j; left++) {
    ll right = left + j;
    for (ll i = left + 1; i < right; i++) {
    if (left == 0 && right == n - 1)
    dp[left][right] = max(nums[left] * nums[i] * nums[right] + dp[left][i] + dp[i][right], dp[left][right]);
    else
    dp[left][right] = max(nums[left] * nums[right] + dp[left][i] + dp[i][right], dp[left][right]);
            }
        }
    }

    return dp[0][n - 1];
}

int main() {
    ll T;
    cin >> T;
    for (ll t = 1; t <= T; t++) {
    ll siz;
    cin >> siz;
    ll A[siz];
    for (ll i = 0; i < siz; i++) {
    cin >> A[i];
    }
    ll ans = maxcoins(A, siz);
    cout << "#" << t << ans << endl;
    }

    return 0;
}


Samsung โœ…
int sameSubstring(string s, string t, int K){
    int n = s.size();
    int cost = 0, len = 0, res = 0;

    for(int i = 0; i < n; i++){
        cost += abs(s[i] - t[i]);
        len++;

        while(cost > K){
            cost -= abs(s[i - len + 1] - t[i - len + 1]);
            len--;
        }
        res = max(res, len);
    }
    return res;
}

RoundGlass โœ…
const int MOD = 1e9 + 7;
int solve (int N, const vector<int>& rollMax) {
    vector<vector<vector<int>>> dp(N, vector<vector<int>>(6, vector<int>(61, 0)));

    for (int j = 0; j < 6; ++j) {
        dp[0][j][1] = 1;
    }
    for (int i = 1; i < N; ++i) {
        for (int j = 0; j < 6; ++j) { 
            for (int k = 1; k <= rollMax[j]; ++k) { 
                if (k > 1) {
                    dp[i][j][k] = dp[i - 1][j][k - 1];
                }
                for (int m = 0; m < 6; ++m) {
                    if (m != j) {
                        dp[i][m][1] = (dp[i][m][1] + dp[i - 1][j][k]) % MOD;
                    }
                }
            }
        }
    }
    int total = 0;
    for (int j = 0; j < 6; ++j) {
        for (int k = 1; k <= rollMax[j]; ++k) {
            total = (total + dp[N - 1][j][k]) % MOD;
        }
    }

    return total;
}

RoundGlass โœ