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

using ll = long long;

void dfs(int v, int pre, vector<vector<int>>& T, vector<ll>& sz, ll n, ll& ans) {
    ll sum1 = 0, sum2 = 0;
    for (int c : T[v]) {
        if (c == pre) continue;
        dfs(c, v, T, sz, n, ans);
        sum1 += sz[c];
        sum2 += sz[c] * sz[c];
        sz[v] += sz[c];
    }
    sum1 += n - sz[v];
    sum2 += (n - sz[v]) * (n - sz[v]);
    ans -= (sum1 * sum1 - sum2) >> 1;
}

int countTriplets(int treeNodes, vector<int>& treeFrom, vector<int>& treeTo) {
    vector<vector<int>> T(treeNodes + 1);
    for (int i = 0; i < treeNodes - 1; i++) {
        T[treeFrom[i]].push_back(treeTo[i]);
        T[treeTo[i]].push_back(treeFrom[i]);
    }

    ll ans = treeNodes * (treeNodes - 1) * (treeNodes - 2) / 6;
    vector<ll> sz(treeNodes + 1, 1);
    dfs(1, -1, T, sz, treeNodes, ans);
    return ans;
}

int main() {
    int treeNodes = 5;
    vector<int> treeFrom = {1, 1, 2, 2};
    vector<int> treeTo = {2, 5, 3, 4};

    cout << countTriplets(treeNodes, treeFrom, treeTo) << '\n';
    return 0;
}

Count tree path
Gamekraft โœ…
๐Ÿ”ฅ1
const char* oldest(struct companyProfile* profiles, int n) 
{
    int maxSize=profiles[0].size;
    const char* ans=profiles[0].name;
    for (int i=1;i<n;i++)
    {
        if (profiles[i].size>maxSize)
        {
            maxSize=profiles[i].size;
            ans=profiles[i].name;
        }
    }
    return ans;
}
float average(struct companyProfile* profiles, int n)
{
    if (n==0) return 0.0f;
    int ans = 0;
    for (int i=0;i<n;i++)
    {
        ans+=profiles[i].size;
    }
    return (float)ans/n;
}


Company Profiles โœ…
https://www.linkedin.com/jobs/view/4004773127/

Walk-In For "Only Freshers (Except BE / B.Tech)-Data" at Pune Location on 25th Aug


Note: Please carry copy of this email to the venue and make sure you register your application before attending the walk-in. Please mention Candidate ID on top of the Resume ***Please use below link to apply and register your application.


https://career.infosys.com/jobdesc?jobReferenceCode=PROGEN-HRODIRECT-188901



Interview Information:

Interview Date: 25th Aug 2024
Interview Time: 09:30 Am till 12:30 Pm


Interview Venue - Pune:

Pune Venue:

Infosys BPM limited,

Taluka Mulshi,

Plot No. 1, Pune, Phase 1,

Hinjawadi Rajiv Gandhi infotech Park,

Hinjawadi, Pune,

Maharashtra 411057



Documents to Carry:

Please carry 2 set of updated CV(Hard Copy).
Please carry Face Mask**.
Carry any 2 photo Identity proof (PAN Card/Driving License/Voters ID card/Passport).
All original education documents need to be available for verification. (10th, 12th, Graduation (Sem Wise Marksheet, CMM. Provisional and Original Degree)


Job Description:

Job Location: Pune
Qualification: Any Graduate B-Com, BBA, BCA (Except BE / Technical)
Shifts: 24*7
Experience: 0-1 Years
Role: Process Executive


NOTE: Only looking for Freshers & Talents should have graduation completion certificate and mark sheets for onboarding.



Basic requirements:

Decent communication.
Ready to work in night shift
Work from office.


Roles & Responsibilities:

Candidate needs to have 15 years of full time education
Proficient with basic computer knowledge
Candidate should be flexible to work in 24*7 environments, comfortable to work in night shifts (Rotational)
Excellent verbal, written communication, interpretation and active listening skills
Ability to quickly and efficiently assimilate process knowledge
Effective probing & analyzing skills and capable of doing a multi-tasking of voice & data entry
Should be comfortable working from office
๐Ÿ‘4
def smallestString(N, A):
    def is_substring(sub, strings):
        return any(sub in s for s in strings)

    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    for c in alphabet:
        if not is_substring(c, A):
            return c
   
    for c1 in alphabet:
        for c2 in alphabet:
            s = c1 + c2
            if not is_substring(s, A):
                return s
    return ""

Smallest substring Egnyte โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
using namespace std;
int count(const unordered_set<int> &a, const unordered_set<int> &b) {
    int r = 0;
    for (int x : a) {
        r += b.count(x);
    }
    return r;
}

void better(int& r, int &num, int id, int count) {
    if (r < 0  or (num < count or   ((num == count) && (r > id)))) {
        r = id;
        num = count;
    }
}

vector<int> getRecommendedFriends(int n, const vector<vector<int>> friendships) {
     vector<int> r(n, -1), num(n, 0);
    vector<unordered_set<int>> con(n);
    for (const auto& v : friendships) {
        con[v[0]].insert(v[1]);
        con[v[1]].insert(v[0]);
    }
  

    for (int i = 0; i<n; ++i) {
        for (auto t1 = con[i].begin(); t1 != con[i].end(); ++t1) {
            for (auto t2 = next(t1); t2 != con[i].end(); ++t2) {
              
                if (con[*t1].count(*t2) == 0) {
                    const int x = count(con[*t1], con[*t2]);
                    better(r[*t1], num[*t1], *t2, x);
                    better(r[*t2], num[*t2], *t1, x);
                }
               
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        if (r[i] < 0) {
            int j = 0;
            for (; j < n && (j == i) || con[i].count(j); ++j);
            if (j < n) {
                r[i] = j;
            }
        }
   
    }
    return r;
}

Social Media suggestions
BNY Mellon โœ…
class Solution {
public:
    vector<int> countServers(int n, vector<vector<int>>& logs, int x, vector<int>& queries) {
        sort(logs.begin(), logs.end(), [](const auto& a, const auto& b) {
            return a[1] < b[1];
        });
        int m = queries.size();
        vector<pair<int, int>> qs(m);
        for (int i = 0; i < m; ++i) {
            qs[i] = {queries[i], i};
        }
        sort(qs.begin(), qs.end());
        unordered_map<int, int> cnt;
        vector<int> ans(m);
        int j = 0, k = 0;
        for (auto& [r, i] : qs) {
            int l = r - x;
            while (k < logs.size() && logs[k][1] <= r) {
                ++cnt[logs[k++][0]];
            }
            while (j < logs.size() && logs[j][1] < l) {
                if (--cnt[logs[j][0]] == 0) {
                    cnt.erase(logs[j][0]);
                }
                ++j;
            }
            ans[i] = n - cnt.size();
        }
        return ans;
    }
};


BNY Mellon โœ…
LOG ANALYSIS 2
public static int findMaximumZeroes(int[] arr) {
        int n = arr.length;
        int ans = 1;
        int mini = arr[0];

        for (int i = 1; i < n; i++) {
            if (arr[i] <= mini) {
                ans++;
            }
            mini = Math.min(mini, arr[i]);
        }

        return ans;
    }

Amazon โœ…
๐Ÿ‘2โค1๐Ÿ‘Ž1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
using namespace std;
long long getMaxReliability(int maxConnections, int gnodes, vector<int> g_from, vector<int> g_to, vector<int> g_weight) {
    vector<vector<pair<int, int>>> adj(gnodes);

    for (int i = 0; i < gnodes - 1; ++i) {
        adj[g_from[i]].emplace_back(g_to[i], g_weight[i]);
        adj[g_to[i]].emplace_back(g_from[i], g_weight[i]);
    }

    function<array<long long, 2>(int, int)> dfs = [&](int cur, int parent) {
        array<long long, 2> ans{};
        vector<long long> take, skip, diff;

        for (auto& [next, w] : adj[cur]) {
            if (parent != next) {
                auto [not_full, full] = dfs(next, cur);
                take.push_back(not_full + w);
                skip.push_back(full);
                diff.push_back(take.back() - skip.back());
            }
        }

        int n = int(diff.size());
        nth_element(diff.begin(), diff.begin() + maxConnections - 1, diff.end(), greater<>());
        ans[0] = accumulate(diff.begin(), diff.begin() + min(maxConnections, n), 0LL) + accumulate(skip.begin(), skip.end(), 0LL);
        if (n && n >= maxConnections) {
            ans[1] = ans[0];
            ans[0] -= *min_element(diff.begin(), diff.begin() + maxConnections);
        }

        return ans;
    };
    auto ans = dfs(0, -1);
   // cout << "DFS Result - Not Full: " << ans[0] << ", Full: " << ans[1] << endl;
    return max(ans[0], ans[1]);
}


Get MaxReliability
Gamekraftโœ…
๐Ÿ‘1
#include <bits/stdc++.h>
using namespace std;

int solve(vector<int>& err, int p, int q) {
    make_heap(err.begin(), err.end());
    pop_heap(err.begin(), err.end());
    int base_line = 0;
    int operations = 0;
    while (err.back() > base_line) {
        base_line += q;
        int max_err = err.back();
        err.pop_back();
        err.push_back(max_err - (p - q));
        push_heap(err.begin(), err.end());
        operations += 1;
        pop_heap(err.begin(), err.end());
    }
    return operations;
}