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

import java.util.Arrays;
import java.util.Scanner;

public class HackerRank1 {
    public static String text = "engine";
    public static String prefix = "raven";
    public static String suffix = "ginkgo";

    public static void main(String[] args) {
        String result = calculateScore(text, prefix, suffix);
        System.out.println(result);
    }

    static String calculateScore(String text, String prefix, String suffix) {
        int max = 0;
        int max_pre  = 0;
        String result = "";

        for (int i = 0; i < text.length(); i++) {
            for (int j = i + 1; j <= text.length(); j++) {
                String subStr = text.substring(i, j);
                int pre = findPreLength(subStr, prefix);
                int post = findPostLength(subStr, suffix);

                if(max < (pre + post)) {
                    max = pre + post;
                    result = subStr;
                    max_pre = pre;
                }
                else if(max == pre + post){
                    if(pre > max_pre) {
                        max_pre = pre;
                        result = subStr;
                    }
                    else{
                        String[] arr = {result,subStr};
                        Arrays.sort(arr);
                        if(arr[0].equals(subStr)){
                            result = subStr;
                            max_pre = pre;
                        }
                    }
                }


            }
        }
        return result;
    }


    private static int findPostLength(String subStr, String suffix) {
        int max = 0;
        for (int i = 0; i < subStr.length(); i++) {
            int len = 0;
            String str = subStr.substring(i);
            int k =0;
            for (int j = 0; j <suffix.length() && k < str.length(); j++, k++) {
                if (str.charAt(k) == suffix.charAt(j))
                    len++;
                else
                    break;
            }
            if (len > max && k == str.length())
                max = len;
        }
        return max;
    }


    private static int findPreLength(String subStr, String prefix) {
        int max = 0;
        for (int i = 1; i < subStr.length() + 1; i++) {
            int len = 0;
            int j = prefix.length() - 1;
            String str = subStr.substring(0, i);
            int k =str.length() - 1;

            for (; j >= 0 && k >=0; j--, k--) {
                if (str.charAt(k) == prefix.charAt(j))
                    len++;
                else
                    break;
            }
            if (len > max && k == -1)
                max = len;
        }
        return max;
    }
}

Meesho โœ…
๐Ÿ‘1
def getAnagramPeriod(s):
    n = len(s)
    for i in range(1, n + 1):
        if n % i == 0:
            period = s[:i]
            if sorted(period * (n // i)) == sorted(s):
                return i
    return n