๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.56K photos
3 videos
95 files
9.65K 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 check_similar_passwords(new_passwords, old_passwords):
    ans = []

    for new_pass, old_pass in zip(new_passwords, old_passwords):
        i, j = 0, 0
        while i < len(new_pass) and j < len(old_pass):
            new_char = new_pass[i]
            old_char = old_pass[j]
           
            new_shifted_char = 'a' if new_char == 'z' else chr(ord(new_char) + 1)
           
            if old_char == new_char or old_char == new_shifted_char:
                j += 1
            i += 1
       
        ans.append("YES" if j == len(old_pass) else "NO")

    return ans

new_passwords = ["aaccbbee", "aab"]
old_passwords = ["bdbf", "aee"]
print(check_similar_passwords(new_passwords, old_passwords))


Python 3โœ…
(Amazon)
#include <bits/stdc++.h>

using namespace std;

int getMaxCount(vector<int>people,vector<char>status){
    int i=0;
    int ans=0;
    map<int,int>mp;
    int n=status.size();
    for(int i=0;i<n;i++){
        int bro=people[i];
        if(status[i]=='-'){
            mp[bro]--;
            if(mp[bro]==0){
                mp.erase(bro);
            }
           

        }else{
            mp[bro]++;

        }
        int helo=mp.size();
        ans=max(ans,helo);
    }
    return ans;

}

int main() {
  int n;
  cin>>n;
  vector<int>vec(n);
  vector<char>vec2(n);
  for(int i=0;i<n;i++){
      cin>>vec[i];
  }
  for(int i=0;i<n;i++){
      cin>>vec2[i];
  }
  cout<<getMaxCount(vec,vec2);

  return 0;
}

Amazon Dublin โœ…
long ans = 0;
        for (int i = 0; i < arr.size(); i++)
        {
            map<int, int> m;
            for (int j = i; j < arr.size(); j++)
            {
                m[arr[j]]++;
            }
            ans += m.size();
        }
        return ans;

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

using namespace std;

bool isBalanced(const string& s) {
    int balance = 0;
    for (char c : s) {
        if (c == '[') {
            balance++;
        } else if (c == ']') {
            balance--;
        }
    }
    return balance == 0;
}

string generateRegex(const string& a, const string& b, const string& c) {
    int maxLength = a.size() + b.size() + 4; // 4 accounts for potential "[...]" brackets

    string longestRegex;

    for (int len = maxLength; len >= 0; len--) {
        for (int i = 0; i < a.size(); i++) {
            for (int j = 0; j < b.size(); j++) {
                if (i + len > a.size() || j + len > b.size()) {
                    continue;
                }
                string substrA = a.substr(i, len);
                string substrB = b.substr(j, len);
               
                if (isBalanced(substrA) && isBalanced(substrB)) {
                    string regex = "[" + substrA + substrB + "]";
                    if (regex.find(c) == string::npos && regex.size() > longestRegex.size()) {
                        longestRegex = regex;
                    }
                }
            }
        }
    }

    return longestRegex;
}

int main() {
    string a = "DABCIBC";
    string b = "ABCA";
    string c = "BBCA";

    string longestRegex = generateRegex(a, b, c);

    cout << longestRegex << endl;

    return 0;
}

Amazon Dublin โœ