๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
class Solution { 
    int ring_size;
    unordered_map<char,vector<int>> mp;
    int clockwise(int curr, int new_pos){
        if(new_pos >= curr){
            return new_pos-curr;
        }
        return ring_size - (curr - new_pos);
    }
    int anti_clockwise(int curr, int new_pos){
        if(curr >= new_pos){
            return curr - new_pos;
        }
        return ring_size - (new_pos - curr);
    }
    int solve(string &key, int idx, int pos, vector<vector<int>>& dp){
        if(idx == key.size()){
            return 0; //end of key
        }
        if(dp[idx][pos] != -1){
            return dp[idx][pos];
        }
        int steps = INT_MAX;
        int key_value = key[idx];
        
        //going to all indexes
        for(int i = 0; i < mp[key_value].size(); i++){
            int new_pos = mp[key_value][i];
            int taken = solve(key,idx+1,new_pos,dp);
            //clockwise
            steps = min(steps,1+clockwise(pos,new_pos)+taken);
            //anticlockwise
            steps = min(steps,1+anti_clockwise(pos,new_pos)+taken);
        }
        return dp[idx][pos] = steps;
    }
public:
    int findRotateSteps(string& ring, string& key) {
        ring_size = ring.size();
        for(int i = 0; i < ring_size; i++){
            mp[ring[i]].push_back(i); 
        }

        vector<vector<int>> dp(key.size(),vector<int>(ring.size(),-1));
        return solve(key,0,0,dp);
    }
};


Uber โœ…
#include<bits/stdc++.h>
using namespace std;
const int N=6e6+10000;
int ch[N][2];
int sz[N];
int a[N];
int n,idx;
void insert(int x)
{
int p=0;
for(int i=29;i>=0;i--)
{
  int u=(x>>i)&1;
  if(!ch[p][u]) ch[p][u]=++idx;
  p=ch[p][u];
  ++sz[p];
}
}
int  dfs(int u)
{
int l=ch[u][0],r=ch[u][1];
if(l && r) return min(sz[l]-1+dfs(r),sz[r]-1+dfs(l));

if(l) return dfs(l);
if(r) return dfs(r);
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
  scanf("%d",&a[i]);
  insert(a[i]);
}
printf("%d\n",dfs(0));
}

uber โœ…
for ca in range(int(input())):
  f=True
  s=input()
  t=input()
  a=''
  for i in range(20):
    a+=s
    if len(a)%len(t)==0 and a==t*(len(a)//len(t)):
      print(a)
      f=False
      break
  if f:
    print('NO')

Swaraj
Uber โœ…
int minimumRemovals(vector<int>& arr) {
    int n = arr.size();
    int maxElement = *max_element(arr.begin(), arr.end());
    int minElement = *min_element(arr.begin(), arr.end());
   
    int maxIndex = find(arr.begin(), arr.end(), maxElement) - arr.begin();
    int minIndex = find(arr.begin(), arr.end(), minElement) - arr.begin();
   
    if (maxIndex > minIndex) swap(maxIndex, minIndex);
   
    int removalsFromLeft = minIndex + 1;
    int removalsFromRight = n - maxIndex;
    int removalsBothEnds = maxIndex + 1 + (n - minIndex);
   
    return min({removalsFromLeft, removalsFromRight, removalsBothEnds});
}

Minimum Removals โœ…
int solve(vector<int>& nums)
{
    int N = nums.size();
    int idx1 = min_element(nums.begin(), nums.end()) - nums.begin();
    int idx2 = max_element(nums.begin(), nums.end()) - nums.begin();
    int L = min(idx1, idx2);
    int R = max(idx1, idx2);
    int left = R + L;
    int right = N - L;
    int both = L + 1 + N - R;
    int ans = min({left, right, both});
    return ans;
}
def solve(mat, arr):
    n = len(mat)
    m = len(mat[0])
    ans = {}
    for i in range(n):
        for j in range(m):
            ans[mat[i][j]] = (i, j)
    row = [0] * n
    col = [0] * m
    for num in arr:
        if num in ans:
            r, c = ans[num]
            row[r] += 1
            col[c] += 1
            if row[r] == m or col[c] == n:
                return num
    return -1
๐Ÿ‘1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
#define ll long long
using namespace std;
string solve(string&a,string&b)
{  
    ll n=a.length();
    ll m=b.length();
    unordered_map<char,ll> m1,m2;
    for(char it:a) m1[it]++;
    for(char it:b) m2[it]++;
    string mid="",ans="";
    for (char i='a';i<='z';i++)
    {
        if(m1[i]%2 and m2[i]%2 and mid.length()<=1)  mid=string(2,i);
        if((m1[i]%2 or m2[i]%2) and mid.length()==0) mid=i;
        ans+=string((m1[i]/2+m2[i]/2),i);
    }
    string tt=ans;
    if (mid.length()==2)
    {  
        tt+=mid[0];
        ans+=mid[0];
        sort(begin(ans),end(ans));
        tt=ans+string(rbegin(ans),rend(ans));
    }
    else tt+=mid+string(rbegin(ans),rend(ans));
    return tt;
}
signed main()
{   
        string s,t; cin>>s>>t;
        cout<<solve(s,t);
    return 0;
}
typedef long long ll;
const ll mod = 1e9 + 7;
ll binpow(ll x, ll y, ll mod) {
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % mod;
        x = (x * x) % mod;
        y /= 2;
    }
    return res;
}

int drawingEdge(int n) {
    ll edges = (ll)n * (n - 1) / 2;
    return binpow(2, edges, mod);
}
๐Ÿ‘2
Company โ€“ CodeInterns
Role โ€“ Data Science Intern
Exp. โ€“  Fresher
Apply Here โ€“ https://internshala.com/internship/detail/work-from-home-part-time-data-science-internship-at-codeinterns1721021097?utm_source=cp_link&referral=web_share

Company โ€“ Ozibook Tech Solutions Private Limited
Role โ€“ Business Analytics Intern
Exp. โ€“ Fresher
Apply Here โ€“ https://internshala.com/internship/detail/work-from-home-part-time-business-analytics-internship-at-ozibook-tech-solutions-private-limited1720800501?utm_source=cp_link&referral=web_share

Company โ€“ Vodafone
Role โ€“ Data Analyst
Exp. โ€“ 0-2 yrs
Apply Here โ€“ https://www.foundit.in/job/data-analyst-vodafone-pune-31193135?searchId=7136e162-6fd1-41b3-af85-aa0fc6b1c14a

Company โ€“ Ignitefortune Tech
Role โ€“ Data Science Associate
Exp. โ€“ 0-1 yr
Apply Here โ€“ https://www.naukri.com/job-listings-data-science-associate-ignitefortune-tech-pune-0-to-1-years-140724001970?src=jobsearchDesk&sid=17210278691665089_3&xp=10&px=1&nignbevent_src=jobsearchDeskGNB

Company โ€“ The Golden Rise
Role โ€“ Business Intelligence Analyst
Exp. โ€“ Fresher
Apply Here โ€“ https://www.linkedin.com/jobs/view/3976531202

Company โ€“ Blockchain for the Next Billion
Role โ€“ Data Analyst
Exp. โ€“ 0-5 yrs
Apply Here โ€“ https://www.linkedin.com/jobs/view/3972831179

Company โ€“ ServiceNow
Role โ€“Data Scientist (SQL & Python)
Exp. โ€“ Fresher
Apply Here โ€“ https://www.linkedin.com/jobs/view/3976572885
๐Ÿ‘Ž2๐Ÿ‘1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
class Solution {
public:
            vector<int> countServers(int N, vector<vector<int>>& L, int x, vector<int>& Q) {
        vector<int> idx, res(Q.size(), 0);
        for(int i = 0; i < Q.size(); i++) idx.push_back(i);
        sort(begin(idx), end(idx), [&](auto a, auto b) {return Q[a] < Q[b];});
        sort(begin(L), end(L), [](auto &a, auto &b) {return a[1] < b[1];});
        int p0 = 0, p1 = 0, cnt = 0;
        unordered_map<int, int> mp;
        for(int i = 0; i < idx.size(); i++) {
            while(p1 < L.size() && L[p1][1] <= Q[idx[i]]) if(++mp[L[p1++][0]] == 1) cnt++;
            while(p0 < L.size() && L[p0][1] < Q[idx[i]]-x) if(--mp[L[p0++][0]] == 0) cnt--;
            res[idx[i]] = N - cnt;
        }
        return res;
            }
};

Meesho โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
int mincost(vector<int> &pods,vector<int> &cost){
  map<int,multiset<int>> mp;
  for(int i=0;i<pods.size();i++){
    mp[pods[i]].insert(cost[i]);
  }
  int ans = 0;
  int curr = (*mp.begin()).first,sm = 0;
  multiset<int> se;
  while(1){
    if(se.size()==0){
      if(mp.lower_bound(curr) == mp.end()) break;
      curr = (*mp.lower_bound(curr)).first;
    }

    if(mp.find(curr) != mp.end())
    for(auto &x:mp[curr]){
        se.insert(x);
        sm += x;
    }

    auto it = se.end();
    it--;
    sm -= *it;
    ans += sm;
    se.erase(it);
    curr++;
  }

  return ans;
}

Meesho โœ…
def is_possible(network_nodes, network_from, network_to):
    from collections import defaultdict
   
    tree = defaultdict(list)
    for i in range(len(network_from)):
        tree[network_from[i]].append(network_to[i])
        tree[network_to[i]].append(network_from[i])
   
    result = ['0'] * (network_nodes + 1)
   
    def dfs(node, parent):
        paired = False
        for child in tree[node]:
            if child != parent:
                if not dfs(child, node):
                    if paired:
                        return False
                    paired = True
        if paired:
            result[node] = '1'
            return True
        return False
   
    dfs(1, -1)
   
    return ''.join(result[1:])

network_nodes = 4
network_from = [3,2,1]
network_to = [4,4,2]
print(is_possible(network_nodes, network_from, network_to))

//messho 3