๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.56K photos
3 videos
95 files
9.68K 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
๐Ÿ“Œ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;
}
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
ll getMinMoves(vector<ll>& prices) {
    int n = prices.size();
    if (n < 2) return -1; 
    unordered_map<int, int> freq;
    ll a = INT_MAX;
    ll left = 0, sum = 0;
    for (int right = 0; right < n; ++right) {
        sum += prices[right];
        freq[prices[right]]++;
        while (freq[prices[right]] > 1) {
            minCost = min(a, sum);
            freq[prices[left]]--;
            sum -= prices[left];
            left++;
        }
    }
    return a == INT_MAX ? -1 : a;
}


Amazon โœ…
from collections import defaultdict
def findDominance(s):
    m = len(s[0]) 
    n = len(s)   
    result = []
    for length in range(1, m + 1):
        a = defaultdict(int)
        for string in s:
            prefix = string[:length]
            a[prefix] += 1
        b = max(a.values())
        result.append(b)
    return result


Amazon โœ…
#include <iostream>
#include <vector>
int getMinMoves(vector<int> arr) {
    int n = arr.size();
    bool chk = true;
    int xr = 0;

    for (int i = 0; i < n; ++i) {
        if (arr[i] != 0) chk = false;
        xr = xr ^ arr[i];
    }

    if (chk) return 0;
    else if (xr == 0) return 1;
    else return 2;
}


Amazon โœ…
def getTotalOfferPeriods(sales):
    n = len(sales)
    nextGreater = [n] * n
    prevGreater = [-1] * n
    stack = []

    for i in range(n):
        while stack and sales[stack[-1]] < sales[i]:
            nextGreater[stack.pop()] = i
        stack.append(i)
   
    stack = []

    for j in range(n):
        while stack and sales[stack[-1]] <= sales[j]:
            stack.pop()
        if stack:
            prevGreater[j] = stack[-1]
        stack.append(j)
   
    total = 0
    for i in range(n):
        j = nextGreater[i]
        if j < n and j >= i + 2:
            total += 1
   
    for j in range(n):
        i = prevGreater[j]
        if i != -1 and j >= i + 2:
            total += 1
   
    return total


Amazon โœ…
import sys
def solve():
    input = sys.stdin.read
    data = input().split()
    N = int(data[0])
    K = int(data[1])
    S = data[2]
   
    def calcPoints(s):
        return sum((ord(c) - ord('a') + 1) * (N - i) for i, c in enumerate(s))
   
    if K == 1:
        minPoints = calcPoints(S)
        for _ in range(N - 1):
            S = S[1:] + S[0]
            minPoints = min(minPoints, calcPoints(S))
        print(minPoints)
    else:
        print(calcPoints(''.join(sorted(S))))

solve()


First Wordโœ…
def getNumPerfectPackaging(p):
    MOD = 10**9 + 7
    dp0 = [1] * 6 
    dp1 = [0] * 6 

    for i in range(1, len(p)):
        c = [0] * 6
        for s in range(1, 6):
            c[s] = (c[s-1] + dp0[s]) % MOD
        tot = c[5]
        for s in range(1, 6):
            if p[i] > p[i-1]:
                dp1[s] = c[s-1]
            elif p[i] < p[i-1]:
                dp1[s] = (tot - c[s]) % MOD
            else:
                dp1[s] = (tot - dp0[s]) % MOD
        dp0, dp1 = dp1, [0] * 6 

    return sum(dp0[1:6]) % MOD


Amazon โœ…
def magical_string(n, s):
count = 0
expecting_first = True
current_char = ''
for c in s:
if expecting_first:
current_char = c
expecting_first = False
else:
if c != current_char:
count += 2
expecting_first = True
return n - count

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

using namespace std;

string ltrim(const string &);
string rtrim(const string &);



/*
* Complete the 'minTimeForRobots' function below.
*
* The function is expected to return a LONG_INTEGER.
* The function accepts following parameters:
*  1. INTEGER the_number_of_robots
*  2. INTEGER_ARRAY rack_capacities
*/


#include<bits/stdc++.h>
using ll = long long;
using namespace std;
bool canAllocate(const vector<int>& capacities, ll k, ll maxLoad) {
    ll robotCount = 1;
    ll currentLoad = 0;

    for (int cap : capacities) {
        if (cap > maxLoad) return false;
        if (currentLoad + cap > maxLoad) {
            robotCount++;
            currentLoad = cap;
            if (robotCount > k) return false;
        } else {
            currentLoad += cap;
        }
    }

    return true;
}


long long minTimeForRobots(int the_number_of_robots, std::vector<int> rack_capacities) {
    ll n = rack_capacities.size();
    if (the_number_of_robots == 0) return -1;
    if(the_number_of_robots>n)return *max_element(rack_capacities.begin(), rack_capacities.end());
    ll low = *max_element(rack_capacities.begin(), rack_capacities.end());
    ll high = accumulate(rack_capacities.begin(), rack_capacities.end(), 0l);
    ll result = high;

    while (low <= high) {
        ll mid = low + (high - low) / 2;

        if (canAllocate(rack_capacities, the_number_of_robots, mid)) {
            result = mid;
            high = mid - 1;
        } else {
            low = mid + 1;
        }
    }

    return result;

}

Nvidia โœ…
def maximumXorSum(arr1, arr2):
    n = len(arr1)
    MOD = 10**9 + 7
   
    bit_count1 = [0] * 32
    bit_count2 = [0] * 32
   
    for i in range(n):
        for j in range(32):
            bit_count1[j] += (arr1[i] >> j) & 1
            bit_count2[j] += (arr2[i] >> j) & 1
   
    total_sum = 0
   
    for i in range(32):
        ones = (bit_count1[i] * n) + (bit_count2[i] * n) - (2 * bit_count1[i] * bit_count2[i])
        total_sum = (total_sum + (ones * (1 << i))) % MOD
   
    return total_sum


Oracle โœ…
Maximum Xor matrix Sum