๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
class FibonacciIterator:
    def __init__(self, n):
        self.prev = 0 
        self.curr = 1 
        self.count = 0 
        self.n = n 

    def __iter__(self):
        return self

    def __next__(self):
        if self.count >= self.n:
            raise StopIteration
        fib = self.prev
        self.prev, self.curr = self.curr, self.prev + self.curr 
        self.count += 1
        return fib


Custom Iterator โœ…
Servicenow
def priceCheck(products, productPrices, productSold, soldPrice):
    price_map = {}
    for i in range(len(products)):
        price_map[products[i]] = productPrices[i]
    error_count = 0
    for j in range(len(productSold)):
        correct_price = price_map[productSold[j]] 
        if soldPrice[j] != correct_price:
            error_count += 1
    return error_count


IBMโœ…
Please try to react on the post in case you are applying, it will hardly take your 10 secs but enough to motivate me to share more and more opportunities everyday without fail:)

Just one favour if you canโค๏ธ
โค6๐Ÿคฎ4๐Ÿ‘2๐Ÿ‘Ž1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for(auto &x:h) cin >> x;
    if(k ==1){
        ll total = ((n)*(n+1))/2;
        cout << total;
        return 0;
    }

    vector<pair<ll, ll>> factors;
    ll temp = k;
    for(ll p=2; p*p <=temp; p++){
        if(temp % p ==0){
            ll cnt=0;
            while(temp %p ==0){
                cnt++;
                temp /=p;
            }
            factors.emplace_back(p, cnt);
        }
    }
    if(temp >1){
        factors.emplace_back(temp, 1);
    }
    int m = factors.size();
    vector<vector<ll>> prefix(m, vector<ll>(n+1, 0));
    for(int i=0;i<m;i++){
        ll p = factors[i].first;
        for(int j=0; j<n; j++){
            ll cnt =0;
            ll val = h[j];
            while(val %p ==0){
                cnt++;
                val /=p;
            }
            prefix[i][j+1] = prefix[i][j] + cnt;
        }
    }
    ll total =0;
    for(int right=0; right<n; right++){
        ll l_max = n;
        bool valid = true;
        for(int i=0;i<m;i++){
            ll required = factors[i].second;
            ll limit = prefix[i][right+1] - required;
            if(limit <0){
                valid = false;
                break;
            }
            ll pos = upper_bound(prefix[i].begin(), prefix[i].begin()+right+2, limit) - prefix[i].begin() -1;
            l_max = min(l_max, pos);
        }
        if(valid){
            l_max = min(l_max, (ll)right+1);
            total += (l_max +1);
        }
    }
    cout << total;
}

Beautiful Garden โœ…
Rubrik
โค2๐Ÿคฎ1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
import sys
import threading
import bisect

def main():
    import sys

    sys.setrecursionlimit(1 << 25)
    T = int(sys.stdin.readline())
    for _ in range(T):
        N, M = map(int, sys.stdin.readline().split())
        children = [[] for _ in range(N + 1)]
        C = [0] * (N + 1)
        L = [0] * (N + 1)
        for i in range(1, N + 1):
            line = sys.stdin.readline()
            if not line.strip():
                line = sys.stdin.readline()
            tokens = line.strip().split()
            if len(tokens) !=3:
                RM, cost, leadership = 0, 0, 0
            else:
                RM, cost, leadership = map(int, tokens)
            if i ==1:
                if RM ==1:
                    parent =0
                else:
                    parent = RM
            else:
                parent = RM
            children[parent].append(i)
            C[i] = cost
            L[i] = leadership
        max_happiness = 0

        def dfs(node):
            nonlocal max_happiness
            current_costs = [C[node]]
            current_costs.sort()
            for child in children[node]:
                child_costs = dfs(child)
                if len(child_costs) > len(current_costs):
                    current_costs, child_costs = child_costs, current_costs
                merged = []
                i = j =0
                while i < len(current_costs) and j < len(child_costs):
                    if current_costs[i] < child_costs[j]:
                        merged.append(current_costs[i])
                        i +=1
                    else:
                        merged.append(child_costs[j])
                        j +=1
                while i < len(current_costs):
                    merged.append(current_costs[i])
                    i +=1
                while j < len(child_costs):
                    merged.append(child_costs[j])
                    j +=1
                current_costs = merged
            prefix_sums = [0]
            for cost in current_costs:
                prefix_sums.append(prefix_sums[-1] + cost)
            k = bisect.bisect_right(prefix_sums, M) -1
            happiness = L[node] * k
            if happiness > max_happiness:
                max_happiness = happiness
            return current_costs

        dfs(0)
        print(max_happiness)

threading.Thread(target=main).start()


Human Resources
Rubrik โœ…
๐Ÿ‘1๐Ÿ˜ข1