๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.62K 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 <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
void computeSums(const vector<int>& a, vector<int>& b, int c, int d) {
    if (c == a.size()) {
        b.push_back(d);
        return;
    }

    computeSums(a, b, c + 1, d + a[c]);
    computeSums(a, b, c + 1, d);
}

int main() {
    int e, f;
    cin >> e;

    cin >> f;

    vector<int> g(e);
    for (int h = 0; h < e; h++) {
        cin >> g[h];
    }

    vector<int> i, j;
    computeSums(vector<int>(g.begin(), g.begin() + e / 2), i, 0, 0);
    computeSums(vector<int>(g.begin() + e / 2, g.end()), j, 0, 0);

    unordered_set<int> k(i.begin(), i.end());

    for (int l : j) {
        if (k.count(f - l)) {
            cout << 1 << endl;
            return 0;
        }
    }

    cout << 0 << endl;
    return 0;
}


Calorie combination โœ…
Walmart
๐Ÿ‘2
#include <iostream>
#include <bitset>
using namespace std;

bool isPow2Minus1(int n) {
    return (n & (n + 1)) == 0;
}

int maxSplitAnd(int num) {
    string b = bitset<32>(num).to_string();
    int m = b.find('1');
    b = b.substr(m);
    int maxRes = -1;

    for (int i = 1; i < b.length(); i++) {
        int p1 = stoi(b.substr(0, i), nullptr, 2);
        int p2 = stoi(b.substr(i), nullptr, 2);
        int res = p1 & p2;
        if (isPow2Minus1(res)) {
            maxRes = max(maxRes, res);
        }
    }
    return maxRes;
}

int main() {
    int n;
    cin >> n;
    cout << maxSplitAnd(n) << endl;
    return 0;
}


Break and Join โœ…
๐Ÿ”ฅ1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
using namespace std;

bool comp(pair<int, int> &p1, pair<int, int> &p2) {
    if (p1.first == p2.first) return p1.second > p2.second;
    return p1.first > p2.first;
}

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    int e = 0, f = 0;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        a.push_back({x + y, x});
        e += x;
    }
    sort(a.begin(), a.end(), comp);
    int cnt = 0;
    for (int i = 0; i < n && f <= e; i++) {
        f += a[i].first ,e -= a[i].second;
        cnt++;
    }
    cout << cnt;
    return 0;
}

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

using namespace std;

int find(int *p, int i) {
    if (p[i] == i) return i;
    return find(p, p[i]);
}

void unionSets(int *p, int *r, int x, int y) {
    int xr = find(p, x);
    int yr = find(p, y);
    if (r[xr] < r[yr]) p[xr] = yr;
    else if (r[xr] > r[yr]) p[yr] = xr;
    else {
        p[yr] = xr;
        r[xr]++;
    }
}

int kruskal(int n, vector<tuple<int, int, int>> &edges, bool mx) {
    int p[n], r[n], cost = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
        p[i] = i;
        r[i] = 0;
    }
    sort(edges.begin(), edges.end(), mx {
        return mx ? get<2>(a) > get<2>(b) : get<2>(a) < get<2>(b);
    });
    for (auto &e : edges) {
        int u = get<0>(e), v = get<1>(e), c = get<2>(e);
        if (find(p, u) != find(p, v)) {
            cost += c;
            cnt++;
            unionSets(p, r, u, v);
            if (cnt == n - 1) break;
        }
    }
    return cost;
}

pair<int, int> minMaxCost(int n, vector<int> &h) {
    vector<tuple<int, int, int>> edges;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            edges.emplace_back(i, j, abs(h[i] - h[j]));
        }
    }
    return {kruskal(n, edges, false), kruskal(n, edges, true)};
}

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    auto res = minMaxCost(n, h);
    cout << res.first << " " << res.second << endl;
    return 0;
}

minimum maximum road costโœ…
๐Ÿ“ŒSuma Soft is Hiring for Software Developer (Freshers)

Location: Pune (Aundh)

Experience: Freshers

Notice Period - Immediate joiner only

Skill Set:
.NET & C#: Familiarity is key!
MVC Magic: Understand the MVC architecture.
Web Savvy: Basic knowledge of HTML, CSS, and JavaScript.
Entity Framework Enthusiast: Experience is a plus!
Problem Solver: Strong analytical thinking and a passion for learning.
Why Join Us?
Empowering Environment: Collaborate with a supportive team that values your growth.
Hands-On Experience: Work on exciting projects that make a real impact.
Career Development: Opportunities for continuous learning and professional advancement.


Share your resume: anamika.shukla@sumasoft.net
๐Ÿ‘1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include<bits/stdc++.h>
using namespace std;
#define int long long

int solve(int n, vector<int>& front, vector<int>& back, int frontend, int backend) {
    vector<vector<int>> dp(n + 1, vector<int>(frontend + 1, INT_MAX));
    dp[0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= frontend; j++) {
            if (dp[i][j] == INT_MAX) continue;
            if (j < frontend) {
                dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + front[i]);
            }
            int b = i - j;
            if (b < backend) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + back[i]);
            }
        }
    }

    return dp[n][frontend];
}

int32_t main() {
    int frontend, backend;
    cin >> frontend >> backend;
    int n = frontend + backend;
    vector<int> front(n), back(n);
   
    for (int i = 0; i < n; i++) {
        cin >> front[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> back[i];
    }

    int result = solve(n, front, back, frontend, backend);
    cout << result << endl;

    return 0;
}


Hiring Drive โœ…
#include <iostream>
#include <unordered_set>
#include <string>
using namespace std;
int password_strength(const string& password, int k) {
    unordered_set<string> u;

    if (k > password.length() || k <= 0) {
        return 0;
    }
    for (size_t i = 0; i <= password.length() - k; ++i) {
        string substring = password.substr(i, k);
        u.insert(substring);
    }

    return u.size();
}


Python: Password Strength โœ…
BNY(Intern)
#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll ss(ll A, ll B) {
    ll rounds = 0;
        while (A != B) {
        if (A > B) {
            A -= B;
        } else {
            B -= A;
        }
        rounds++;
    }
   
    return rounds;
}

int main() {
    ll A, B;
    cin >> A >> B;
    cout << ss(A, B) << endl;
    return 0;
}


Rivals โœ…
๐Ÿ‘1
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int solve(int n, int m, int x, vector<int>& a) {

    int rem = m % x;

    if (rem == 0) {
        return m % MOD;
    }

    int minAdd = -1;
    for (int i = 0; i < n; i++) {
        int add = a[i];
        if ((m + add) % x == 0) {
            if (minAdd == -1 || add < minAdd) {
                minAdd = add;
            }
        }
    }

    if (minAdd == -1) {
        return -1;
    }

    return (m + minAdd) % MOD;
}

int main() {
    int t;
    cin >> t;
   
    while (t--) {
        int n, m, x;
        cin >> n >> m >> x;
       
        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }

        int res =solve(n, m, x, a);

        cout << res << endl;
    }

    return 0;
}


Greedy power โœ…
#include <iostream>
#include <vector>
#include <algorithm>

int findOptimalityQuotient(std::vector<int> arr) {
    int n = arr.size();
    sort(arr.begin(), arr.end());
    vector<int> rearranged_arr = arr;
    sort(rearranged_arr.begin(), rearranged_arr.end());

    int greatness_arr = 0;
    int j = 0;

    for (int i = 0; i < n; i++) {
        while (j < n && rearranged_arr[j] <= arr[i]) {
            j++;
        }
        if (j < n) {
            greatness_arr++;
            j++;
        }
    }

    return greatness_arr * 2;
}

Twillo โœ