๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.56K photos
3 videos
95 files
9.7K 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 ss(firstnum: str, secondnum: str, thirdnum: str) -> bool:
    target_sum = int(thirdnum)
    second_value = int(secondnum)
    if int(firstnum) + second_value == target_sum:
        return True
    for i in range(len(firstnum)):
        new_firstnum = firstnum[:i] + firstnum[i+1:]
        if new_firstnum and (new_firstnum[0] != '0'):
            if int(new_firstnum) + second_value == target_sum:
                return True
    return False
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int T;
    cin >> T;
    for(int test_case=1; test_case<=T; test_case++){
        int N;
        cin >> N;
        string S = "";
        cin>>S;
   
        vector<int> pre(2*N +1, 0);
        for(int i=1; i<=2*N; i++){
            if(S[i-1] == 'R'){
                pre[i] = pre[i-1] +1;
            }
            else{
                pre[i] = pre[i-1] -1;
            }
        }

        unordered_map<int, int> dp1,dp2;
        for(int i=0; i<=2*N; i++){
            int d = pre[i];
            if(i <= N){
                if(dp1.find(d) == dp1.end()){
                    dp1[d] = i;
                }
            }
            if(i >= N){
                if(dp2.find(d) == dp2.end() || i > dp2[d]){
                    dp2[d] = i;
                }
            }
        }

        int mx =0;
        for(auto &entry : dp1){
            int d = entry.first;
            if(dp2.find(d) != dp2.end()){
                int last = dp2[d] - entry.second;
                if(last > mx){
                    mx = last;
                }
            }
        }
        int ans = 2 * N - mx;
        cout << "#" << test_case << " " << ans << "\n";
    }
}

Samsung (R&D)โœ…
#include<iostream>
using namespace std;
int solve(vector<int>ribbons, int k)
{
    int low=0, high=*max_element(ribbons.begin(), ribbons.end());
    while(low<high)
    {      
        int mid=(low+high+1)>>1;
        int cnt=0;
        for(int r:ribbons)
            cnt+=r/mid;
           
        if(cnt<k)
            high=mid-1;
        else
            low=mid;
    }
    return low;
}
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i=0;i<N;i++) arr[i] = sc.nextInt();
        int k = sc.nextInt();
        Arrays.sort(arr);
        int left=0, right=N-1, moves=0;
        while(left <= right){
            if(arr[left] + arr[right] <=k) left++;
            right--;
            moves++;
        }
        System.out.println(moves);
    }
}


Zeta โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
import java.util.*;
import java.io.*;

public class Main {
    static class Segment {
        int L;
        int R;
        int cost;
        Segment(int L, int R, int cost){
            this.L = L;
            this.R = R;
            this.cost = cost;
        }
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextInt(); // Read the '3' and ignore
        Segment[] segments = new Segment[N];
        for(int i=0;i<N;i++) {
            int L = sc.nextInt();
            int R = sc.nextInt();
            int cost = sc.nextInt();
            segments[i] = new Segment(L, R, cost);
        }
        Segment[] sortedByL = segments.clone();
        Arrays.sort(sortedByL, new Comparator<Segment>() {
            public int compare(Segment a, Segment b){
                if(a.L != b.L) return Integer.compare(a.L, b.L);
                return Integer.compare(a.R, b.R);
            }
        });
        Segment[] sortedByR = segments.clone();
        Arrays.sort(sortedByR, new Comparator<Segment>() {
            public int compare(Segment a, Segment b){
                if(a.R != b.R) return Integer.compare(a.R, b.R);
                return Integer.compare(a.L, b.L);
            }
        });
        long minCost = Long.MAX_VALUE;
        long minProduct = Long.MAX_VALUE;
        int r_ptr = 0;
        for(int i=0;i<N;i++) {
            Segment current = sortedByL[i];
            while(r_ptr < N && sortedByR[r_ptr].R < current.L){
                if(sortedByR[r_ptr].cost < minCost){
                    minCost = sortedByR[r_ptr].cost;
                }
                r_ptr++;
            }
            if(minCost != Long.MAX_VALUE){
                long product = minCost * (long)current.cost;
                if(product < minProduct){
                    minProduct = product;
                }
            }
        }
        if(minProduct != Long.MAX_VALUE){
            System.out.println(minProduct);
        }
        else{
            System.out.println(-1);
        }
    }
}


Zeta โœ…
int best=0;
int dfs(TreeNode* root) {
   if(root==NULL)return -1;
   int left = dfs(root->left);
   int right = dfs(root->right);
   int res = root->val;
   if(left*right>=0 && left+right>=0) res+=left+right;
   best = max(best,res);
   return res;
}
int maxPerfectSubtree(TreeNode* root) {
   solve(root);
   return best;
}


American Express โœ…
def solution(S):
    r={'AB','BA','CD','DC'}
    s=[]
    for c in S:
        if s and s[-1]+c in r:
            s.pop()
        else:
            s.append(c)
    return ''.join(s)


American Express โœ…
Experience: 0-1 years

Salary: โ‚น6.00 LPA

About Us:

Hummingbird Web Solutions Pvt Ltd specializes in Adobe Commerce services, building top-tier e-commerce solutions worldwide. We offer a supportive and growth-oriented work environment.

Role Highlights:

โ€ข Collaborate with engineering, product, and design teams on client websites

โ€ข Code with JavaScript, ReactJS, PHP, RequireJS, KnockOutJS, AlpineJS, and more

โ€ข Contribute to daily deployments, task management, and release support

โ€ข Share insights to foster innovation within the team

Eligibility:

โ—†Graduated in 2024 in CS, IT, Electronics, or related fields

Coding profile on LeetCode, CodeChef, or Codeforces

* Strong communication skills

Join us at Hummingbird Web Solutions! Apply now if you're ready to make an impact.

Kindly submit the given form to apply with us Link

https://lnkd.in/dBKCUsKd
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
int main() {
    int N;
    cin >> N;
    vector<int> squareFreeDivisorCount(N + 1, 0);
    long long count = 0;
    for (int i = 1; i <= N; ++i) {
        for (int j = i; j <= N; j += i) {
            int product = i * j;
            int root = sqrt(product);
            if (root * root == product) {
                if (i == j)
                    count = (count + 1) % MOD;
                else
                    count = (count + 2) % MOD;
            }
        }
    }

    cout << count << endl;
    return 0;
}


Square investment โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
def getInaccurateProcesses(processOrder, executionOrder):
    class FenwickTree:
        def __init__(self, size):
            self.size = size
            self.tree = [0] * (size + 2) 

        def update(self, index, delta=1):
            while index <= self.size:
                self.tree[index] += delta
                index += index & -index

        def query(self, index):
            res = 0
            while index > 0:
                res += self.tree[index]
                index -= index & -index
            return res

        def range_query(self, left, right):
            if left > right:
                return 0
            return self.query(right) - self.query(left -1)

    n = len(processOrder)
    pid = {}
    for idx, process in enumerate(processOrder):
        pid[process] = idx

    ft = FenwickTree(n)

    inaccurate =0

    for process in executionOrder:
        index = pid[process]
        fti = index +1
        count = ft.query(fti -1)
        if count != index:
            inaccurate +=1
        ft.update(fti)
   
    return inaccurate


Amazon โœ…
def solve(a, b, k):
    n = len(a)
    r = 0
    for i in range(n):
        x = a[i]
        y = b[n - 1 - i]
        v = int(str(x) + str(y))
        if v < k:
            r += 1
    return r

Motiveโœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
#include <bits/stdc++.h> using namespace std; struct Edge {     int u, v, c;     bool operator<(const Edge& other) const {         return c < other.c;     } }; int find(vector<int>& parent, int u) {     if (parent[u] != u) parent[u] = find(parent, parent[u]);โ€ฆ
#include <bits/stdc++.h>
using namespace std;

class DSU {
    vector<int> parent, rank;
public:
    DSU(int n) {
        parent.resize(n + 1);
        rank.resize(n + 1, 0);
        for (int i = 0; i <= n; i++) {
            parent[i] = i;
        }
    }

    int find(int u) {
        if (u != parent[u]) {
            parent[u] = find(parent[u]);
        }
        return parent[u];
    }

    void unite(int u, int v) {
        int root_u = find(u);
        int root_v = find(v);
        if (root_u != root_v) {
            if (rank[root_u] > rank[root_v]) {
                parent[root_v] = root_u;
            } else if (rank[root_u] < rank[root_v]) {
                parent[root_u] = root_v;
            } else {
                parent[root_v] = root_u;
                rank[root_u]++;
            }
        }
    }
};

int solve(int n, vector<vector<int>>& edges) {
   
    sort(edges.begin(), edges.end(), [](vector<int>& a, vector<int>& b) {
        return a[2] > b[2];
    });

    DSU dsu(n);
    int mst_weight = 0;
    int total_weight = 0;

    for (const auto& edge : edges) {
        total_weight += edge[2];
    }

    for (const auto& edge : edges) {
        int u = edge[0], v = edge[1], w = edge[2];
        if (dsu.find(u) != dsu.find(v)) {
            dsu.unite(u, v);
            mst_weight += w;
        }
    }

    return total_weight - mst_weight;
}

int main() {
    int t;
    cin >> t;
    while (t--){
        int n;
        cin >> n;
        vector<vector<int>> edges(n - 1);

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

        cout << solve(n, edges) << endl;
    }

    return 0;
}

Break and Add โœ…
Google