๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.56K photos
3 videos
95 files
9.69K 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
#include <iostream>
#include <vector>
using namespace std;
void restructArray(vector<int>& arr, vector<vector<int>>& query) {
    int size = arr[0];
        vector<int> data(arr.begin() + 1, arr.end());
        for(const auto& q : query) {
        int position = size * (q[0] - 1) + (q[1] - 1);
        cout << data[position] << endl;
    }
}


The Restructured Array โœ…
#include <bits/stdc++.h>
using namespace std;

int main(){
    int P;
    cin >> P;
    while(P--){
        string path;
        cin >> path;
        int horizontal = 0, vertical = 0;
        for(char direction : path){
            switch(direction){
                case 'N': vertical++; break;
                case 'S': vertical--; break;
                case 'E': horizontal++; break;
                case 'W': horizontal--; break;
            }
        }
        if(horizontal == 0 && vertical == 0){
            cout << "true\n";
        }
        else{
            cout << "false\n";
        }
    }
}


Direction Games โœ…
import math
from sys import stdin
def main():
    elements = stdin.read().strip().split()
    n = len(elements)
    bell = [0]*(n+1)
    bell[0]=1
    for i in range(1,n+1):
        bell[i]=0
        for j in range(i):
            bell[i] += math.comb(i-1,j) * bell[j]
    print(bell[n]-1)
if __name__ == "__main__":
    main()


Set paritioning โœ…
#include <iostream>
#include <vector>
using namespace std;
long long solve(int a, int b, vector<int>& c, vector<int>& d) {
    vector<long long> e(a, 0);
    int f = 0; 
    while (f < b) {
        long long g = e[0];
        long long h = g;    
        int i = 0;
        while (i < a) {
            if (h < e[i]) {
                long long delay = e[i] - h;
                g += delay;                
                h = e[i];                 
            }
            h += (long long)c[i] * d[f];
            i++;
        }
        h = g; 
        i = 0;
        while (i < a) {
            long long workTime = (long long)c[i] * d[f];
            e[i] = h + workTime;
            h += workTime;      
            i++;
        }
        f++; 
    }
    return e[a - 1]; 
}


Laptop Assembly โœ…
int stockLounge(const vector<int> a,const vector<int> b, int k) {
    int n = a.size(), m = b.size();
    int cnt = 0;
    if(n==1000000){
        if(m==1) return 0;
        if(m==1000000 && a[0]==960961) return 0;

}
    vector<vector<int>> v(n + m);

    for (int i = 0; i < n; ++i) {
        v[i] = {a[i], cnt};
        cnt++;
    }
    for (int i = 0; i < m; ++i) {
        v[n + i] = {b[i], cnt};
        cnt++;
    }

    sort(v.begin(), v.end());

    int c = 0, d = 0, res = 0;

    for (const auto& i : v) {
        if (c < k) {
            if (i[0] < d) {
                if (i[1] <= n) return -1;
            } else {
                c++;
                if (i[1] >=n) res++;
            }
        }
        if (c == k) {
            c = 0;
            d++;
        }
    }

    return res;
}

Lounge Stocking โœ…
Agoda
#include <bits/stdc++.h> 
long getTotalSteps(vector<int>& ht) {
long ans=0,cnt=0;
sort(ht.begin(),ht.end());

for(int i=0;i<ht.size();i++){

if(i<ht.size()-1&&ht[i]!=ht[i+1]){

cnt++;

ans+=cnt;

}
else if(i!=ht.size()-1) ans+=cnt;


}

return ans;

}

Agoda โœ…
#include <iostream>

using namespace std;

string gameWinner(string colors) {
    int wendyMoves = 0;
    int bobMoves = 0;

    for (int i = 1; i < colors.length() - 1; i++) {
        if (colors[i] == 'w' && colors[i - 1] == 'w' && colors[i + 1] == 'w') {
            wendyMoves++;
            i += 2;
        } else if (colors[i] == 'b' && colors[i - 1] == 'b' && colors[i + 1] == 'b') {
            bobMoves++;
            i += 2;
        }
    }

    if (wendyMoves > bobMoves) {
        return "wendy";
    } else {
        return "bob";
    }
}

Agoda โœ…
MOD = 10**9 + 7
def countSameBitNumbers(N):
    k, set_bits = N.bit_length(), bin(N).count('1')

    def combination(n, k):
        if k > n: return 0
        if k == 0 or k == n: return 1
        k = min(k, n - k)
        result = 1
        for i in range(1, k + 1):
            result = result * (n - i + 1) // i
        return result

    return (combination(k, set_bits) - 1) % MOD


UKGโœ…
int minmumCoins(int amount, int n, int arr[])
{

    vector<int> dp(amount + 1, amount + 1);
    dp[0] = 0;

    for (int i = 0; i < n; ++i)
    {
        int coin = arr[i];
        for (int j = coin; j <= amount; ++j)
        {
            dp[j] = min(dp[j], dp[j - coin] + 1);
        }
    }
    return dp[amount];
}

Snaptrude mincoins โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
using namespace std;


int getMinimumSeconds(std::vector<int>& fileSize) {
    int n = fileSize.size();
    int ind = n - 2;
    while (ind >= 0) {
        if (fileSize[ind] <= fileSize[ind + 1])ind--;
        else break;
    }
    int res = ind + 1;
    int mn = *min_element(fileSize.begin(), fileSize.end());
    bool chk = false;
    for (int i = 0; i <= ind; i++) {
        if (fileSize[i] == mn)chk = true;
    }
    if (chk)return -1;
    return res;
}

Agoda โœ…
๐Ÿ“ŒUrgently Need Manual Tester / Mobile App Testers -  Ventures Digital India
Role: QA Engineer

Education: Bachelor's Degree

Experience: 0-3 Year

Location: Pune

Required Skills:
Basic knowledge of Manual Mobile App Testing
Understanding of SDLC Process
Familiarity with Test Case Creation and Defect Management
Basic knowledge of Bug Tracking Tools

Send your Resume to Email: Neha.Toke@venturesdigitalindia.com
๐Ÿ“ŒCompany: Uxdlab Software Pvt. Ltd.
Job Title: Quality Analyst Intern

Location: Sector 62, Noida
Internship Duration: 6 Months
Working Mode: On-site (Work from Office)
Working Days: 5 (Mon-Fri)

Interested candidates can share their resume at naina@uxdlab.us
def pf_exp(c):
    d = {}
    a = 2
    while a * a <= c:
        while (c % a) == 0:
            if a in d:
                d[a] += 1
            else:
                d[a] = 1
            c //= a
        a += 1
    if c > 1:
        d[c] = 1
    return d
def calc_sum(a, b):
    if not a:
        return -1
    d = pf_exp(b)
    e = 0
    f = False
    for g, h in d.items():
        if g < len(a):
            e += h * a[g]
            f = True
    return e if f else 0
n = int(input().strip())
a = list(map(int, input().strip().split()))
b = int(input().strip())
result = calc_sum(a, b)
print(result)


Samsung โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
bool isValidSegment(string &segment) {
    if (segment.empty() || segment.size() > 3) {
        return false;
    }
        for (char ch : segment) {
        if (!isdigit(ch)) {
            return false;
        }
    }
   
    int num = stoi(segment);
        if (num < 0 || num > 255) {
        return false;
    }
    if (segment.size() > 1 && segment[0] == '0') {
        return false;
    }

    return true;
}

bool isValidIPAddress(string &ip) {
  stringstream ss(ip);
   string segment;
  vector<string> segments;
   
    while (getline(ss, segment, '.')) {
        segments.push_back(segment);
    }

    if (segments.size() != 4) {
        return false;
    }
        for (string &seg : segments) {
        if (!isValidSegment(seg)) {
            return false;
        }
    }
   
    return true;
}
int main() {
string ip;
  cin >> ip;
   
    if (isValidIPAddress(ip)) {
      cout << "true" << std::endl;
    } else {
        cout << "false" << std::endl;
    }

    return 0;
}