๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
vector<int>findSubsequence(vector<int>arr) {
  map<int, vector<int>> ind;
    for (int i = 0; i < arr.size(); ++i) {
        ind[arr[i]].push_back(i);
    }
   
    vector<int> res;
    res.push_back(-1);
   
    for (auto &[_, v] : ind) {
        if (v.size() <= 1) continue;
       
        int cnt = 0;
        for (auto it : v) {
            if (res.back() > it) continue;
            cnt++;
            res.push_back(it);
            if (cnt == v.size() - 1) break;
        }
       
        if (cnt < v.size() - 1) {
            return { -1 };
        }
    }
   
    vector<int> fres;
    for (int i = 1; i < res.size(); ++i) {
        fres.push_back(arr[res[i]]);
    }
   
    return fres;



findSubsequence

Lindkdin all passed
โœ…
import java.util.*;

public class AnagramSubsequenceFinder {
   
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       
        String S = sc.nextLine();
       
        int N = sc.nextInt();
        sc.nextLine();
        String[] W = new String[N];
        for (int i = 0; i < N; i++) {
            W[i] = sc.nextLine();
        }
       
        int[] freqS = getFrequency(S);
       
        int count = 0;
        for (String w : W) {
            if (isValidAnagramSubsequence(freqS, w)) {
                count++;
            }
        }
       
        System.out.println(count);
    }
   
    private static int[] getFrequency(String S) {
        int[] freq = new int[26];
        for (char c : S.toCharArray()) {
            freq[c - 'a']++;
        }
        return freq;
    }

    private static boolean isValidAnagramSubsequence(int[] freqS, String w) {
        int[] freqW = new int[26];
        for (char c : w.toCharArray()) {
            freqW[c - 'a']++;
        }
       
        for (int i = 0; i < 26; i++) {
            if (freqW[i] > freqS[i]) {
                return false;
            }
        }
       
        return true;
    }
}


// Minimal substring length
def minimumSquads(parents):
    n = len(parents)
    depth = [-1] * n

    def calculate_depth(node):
        if depth[node] != -1:
            return depth[node]
        if parents[node] == -1:
            depth[node] = 0
        else:
            depth[node] = calculate_depth(parents[node]) + 1
        return depth[node]

    max_depth = 0
    for i in range(n):
        max_depth = max(max_depth, calculate_depth(i))

    return max_depth + 1

Minimum squads โœ…
Company โ€“ IIDE Education Private Limited
Role โ€“ Data Analyst Internship
Exp. โ€“ Fresher
Apply Here โ€“ https://internshala.com/internship/detail/data-analyst-internship-in-mumbai-at-iide-education-private-limited1720264879?utm_source=cp_link&referral=web_share

Company โ€“ Blackcoffer
Role โ€“ Data Science Internship
Exp. โ€“ Fresher
Apply Here โ€“ https://internshala.com/internship/details/work-from-home-data-science-internship-at-blackcoffer1720199867?utm_source=cp_link&referral=web_share

Company โ€“ AskmeOffers.com
Role โ€“ Data Analyst
Exp. โ€“ Fresher
Apply Here โ€“ https://www.linkedin.com/jobs/view/3965852124

Company โ€“ White Gold Bullion Private Limited
Role โ€“ Mis Executive
Exp. โ€“ 0-3 yrs
Apply Here โ€“ https://www.foundit.in/job/mis-executive-white-gold-bullion-private-limited-bengaluru-bangalore-31074671?searchId=b0b11ba6-607b-4d50-91c9-b823e3ce49dd

Company โ€“ Blockchain for the Next Billion
Role โ€“ Data Analyst
Exp. โ€“ 0-5 yrs
Apply Here โ€“ https://www.linkedin.com/jobs/view/3966385446
class Solution {
public:
  int minOperations(vector<int>& nums, int x, int y) {
    int l = 0;
    int r = ranges::max(nums);

    while (l < r) {
      const int m = (l + r) / 2;
      if (isPossible(nums, x, y, m))
        r = m;
      else
        l = m + 1;
    }

    return l;
  }

private:
  bool isPossible(const vector<int>& nums, int x, int y, int m) {
    long long additionalOps = 0;
    for (const int num : nums)
      additionalOps += max(0LL, (num - 1LL * y * m + x - y - 1) / (x - y));
    return additionalOps <= m;
  }
};

Citadel โœ