๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.56K photos
3 videos
95 files
9.66K 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 โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
bool isValidMove(int x, int y, const vector<vector<char>>& maze, char forb) {
    int rows = maze.size();
    int cols = maze[0].size();
    return x >= 0 && x < rows && y >= 0 && y < cols && maze[x][y] != forb;
}

int bfs(const vector<vector<char>>& maze, char forb) {
    int rows = maze.size();
    int cols = maze[0].size();
    pair<int, int> start = make_pair(0, 0);
    pair<int, int> end = make_pair(rows - 1, cols - 1);
   
    vector<vector<bool>> visited(rows, vector<bool>(cols, false));
    deque<tuple<int, int, int>> queue;
    queue.push_back(make_tuple(start.first, start.second, 0));

    while (!queue.empty()) {
        int x, y, length;
        tie(x, y, length) = queue.front();
        queue.pop_front();

        if (make_pair(x, y) == end) {
            return length;
        }

        if (!visited[x][y]) {
            visited[x][y] = true;

            int dx[] = {1, -1, 0, 0};
            int dy[] = {0, 0, 1, -1};

            for (int i = 0; i < 4; ++i) {
                int new_x = x + dx[i];
                int new_y = y + dy[i];

                if (isValidMove(new_x, new_y, maze, forb)) {
                    queue.push_back(make_tuple(new_x, new_y, length + 1));
                }
            }
        }
    }

    return -1;  // No path found
}

The Maze Runner โœ…
int maximumLearning(vector<int>& articles, vector<int>& iv, int p) {
    int n = articles.size();
    vector<pair<int, int>> associated;
    for (int i = 0; i < n; ++i) {
        associated.push_back({2 * articles[i], iv[i]});
    }

    int maxIntelValue = 0;
    for (int mask = 0; mask < (1 << n); ++mask) {
        int pagesRead = 0;
        int currentValue = 0;

        for (int i = 0; i < n; ++i) {
            if (mask & (1 << i)) {
                if (pagesRead + associated[i].first <= p) {
                    pagesRead += associated[i].first;
                    currentValue += associated[i].second;
                }
            }
        }

        maxIntelValue = max(maxIntelValue, currentValue);
    }

    return maxIntelValue;
}

Atlassian โœ…
typedef long long ll;

pair<ll, ll> dfs(ll curr, ll prv, const vector<vector<ll>>& adj, const vector<ll>& connect_val, ll k) {
    ll tmp = connect_val[curr - 1];
    pair<ll, ll> ans = {tmp, tmp};

    for (ll x : adj[curr]) {
        if (x == prv) continue;
        auto tmp = dfs(x, curr, adj, connect_val, k);
        ans.second += tmp.second;
        ans.first += tmp.first;
    }

    ans.first = max(ans.first, -k);

    return ans;
}

long long get_max_efficiency(ll connect_nodes, const vector<ll>& connect_from, const vector<ll>& connect_to, const vector<ll>& connect_val, ll k) {
    ll n = connect_nodes;
    vector<vector<ll>> adj(n + 1);

    for (ll i = 0; i < connect_from.size(); i++) {
        ll u = connect_from[i], v = connect_to[i];
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    return dfs(1, 0, adj, connect_val, k).first;
}

Graph one
Atlassian โœ…
ll solve(ll n, ll m, ll k) {
    vector<int>a(n, 1);
    k--;
    ll sum = n, maxjob = 1;

    while(sum <= m) {
        a[k]++;
        maxjob = a[k];

        for(ll i = k - 1; i >= 0; i--) {
            if(a[i + 1] - a[i] > 1) a[i]++;
        }

        for(ll i = k + 1; i < n; i++) {
            if(a[i - 1] - a[i] > 1) a[i]++;
        }
        sum = 0;
        for(ll i = 0; i < n; i++) sum += a[i];
    }
}

Job one
Atlassian โœ…
ZS is hiring for DAA

Qualifications:

โ€ข 0-2 years of experience.

โ€ข Bachelor's degree in any engineering discipline, MIS, operations management, or other relevant degree.

โ€ข Proficiency in MS Excel, Python, SQL and regression techniques.

if you interested send ur resume &Referral

varunvj181@gmail.com
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

const int MAXN = 105;
const int LOGN = 20;

int n;
vector<int> adj[MAXN];
char label[MAXN];
int parent[MAXN][LOGN];
int depth[MAXN];
int freq[MAXN][26];

void dfs(int node, int par, int d) {
    parent[node][0] = par;
    depth[node] = d;

    for (int i = 1; i < LOGN; ++i) {
        if (parent[node][i - 1] != -1) {
            parent[node][i] = parent[parent[node][i - 1]][i - 1];
        }
    }

    for (int child : adj[node]) {
        if (child != par) {
            dfs(child, node, d + 1);
        }
    }
}

void preprocess() {
    memset(parent, -1, sizeof(parent));
    dfs(1, -1, 0);

    for (int node = 1; node <= n; ++node) {
        freq[node][label[node] - 'a']++;
        for (int i = 0; i < 26; ++i) {
            freq[node][i] += freq[parent[node][0]][i];
        }
    }
}

int lca(int u, int v) {
    if (depth[u] < depth[v]) {
        swap(u, v);
    }

    int diff = depth[u] - depth[v];
    for (int i = 0; i < LOGN; ++i) {
        if ((diff >> i) & 1) {
            u = parent[u][i];
        }
    }

    if (u == v) {
        return u;
    }

    for (int i = LOGN - 1; i >= 0; --i) {
        if (parent[u][i] != parent[v][i]) {
            u = parent[u][i];
            v = parent[v][i];
        }
    }

    return parent[u][0];
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> label[i];
    }

    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    preprocess();

    int q;
    cin >> q;
    while (q--) {
        int u, v;
        char c;
        cin >> u >> v >> c;

        int l = lca(u, v);
        int ans = freq[u][c - 'a'] + freq[v][c - 'a'] - 2 * freq[l][c - 'a'] + (label[l] == c);
        cout << ans << endl;
    }

    return 0;
}

Colored Vertex โœ