๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
Airblack is hiring for FullStack Development Interns (2023, 2024 and 2025 passouts can go for it, if you have relevant projects)

Location: Gurugram

Duration: 6 months

If interested, send your resume over dev@airblack.com

While sending resume ache se apne projects ko describe krna, based on that selection hona yaha pr.
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007

ll dp[1005][3];
int N, L, R;

ll solve(int pos, int sum) {
    if (pos == N) return (sum == 0);
    if (dp[pos][sum] != -1) return dp[pos][sum];
    ll ans = 0;
    for (int i = L; i <= R; i++) {
        ans = (ans + solve(pos + 1, (sum + i) % 3)) % mod;
    }
    return dp[pos][sum] = ans;
}

int main() {
    cin >> N >> L >> R;
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0) << endl;
    return 0;
}

Uber She ++โœ…
#include<bits/stdc++.h>
using namespace std;

#define ll long long

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> bombs(N);
    for(int i = 0; i < N; i++)
        cin >> bombs[i].first >> bombs[i].second;
   
    sort(bombs.begin(), bombs.end(), [](const auto &a, const auto &b) {
        return a.second < b.second;
    });

    ll time = 0;
    for(int i = 0; i < N; i++) {
        time += bombs[i].first;
        if(time > bombs[i].second) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << time << endl;
    return 0;
}

Uber She ++โœ…
map<long long, long long> m;

long long solve(long long i, long long uc, long long n, long long x, long long y) {
    long long k1 = i | (uc << 10);
    if (m.find(k1) != m.end())
        return m[k1];
    if (i == n) {
        long long j = uc;
        while (uc > 0) {
            long long k = uc % 10;
            if (k != x && k != y)
                return 0;
            uc = uc / 10;
        }
        return 1;
    }
    long long ans = 0;
    for (long long j = 0; j <= 9; j++) {
        ans += solve(i + 1, uc + 1LL * j, n, x, y);
    }
    return m[k1] = ans;
}

long long solution(int x, int y, int n) {
    long long ans = 0;
    for (long long i = 1; i <= 9; i++) {
        m.clear();
        ans += solve(1, i, n, x, y);
    }
    return ans;
}

Distinct Digits โœ…
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> arr(n);

    for (int i = 0; i < n; ++i)
        cin >> arr[i];

    for (int i = 0; i < n; ++i) {
        auto it = find(arr.begin() + i + 1, arr.end(), arr[i]);
        if (it != arr.end())
            cout << "1 ";
        else
            cout << "-1 ";
    }

    return 0;
}

Walmart โœ…
def func():
    nums = list(map(int, input().split()))
   
    if not nums: return 0
    dp = {}
   
    for num in nums:
        if num / 3 in dp: dp[num] = dp[num / 3] + 1
        else: dp[num] = 1

    return max(dp.values())
   

print(func())

Triple Subsequence โœ…
Walmart
def func():
    n = int(input())
    grid = []
    for i in range(n):
        a, b = map(int, input().split())
        grid.append((a, b))
       
    k = int(input())
    distances = [(x2 + y2, (x, y)) for x, y in grid]
   
    distances.sort()
    res = [point for _, point in distances[:k]]
    for i in range(k):
        print(res[i][0], res[i][1])

func()

Alice playing game โœ…
Walmart
int inv(int a) {
  return a <= 1 ? a : mod - (long long)(mod/a) * inv(mod % a) % mod;
}
int solve(vector<int>nums){
    int n = nums.size();
    vector<int> ans;


    ans.push_back(nums[0]);

    for (int i = 1; i < n; i++) {
        if (nums[i] > ans.back()) {
            ans.push_back(nums[i]);
        }
        else {

           
            int low = lower_bound(ans.begin(), ans.end(),
                                  nums[i])
                      - ans.begin();

           
            ans[low] = nums[i];
        }
    }

   
    return inv(ans.size());
}

Books โœ…
Walmart
def func():
    n, k = map(int, input().split())
    arr = list(map(int, input().split()))
       
    dp = [float('inf')] * (n + 1)
    dp[0] = 0

    q = deque()

    for i in range(1, n + 1):
       
        while q and q[0] < i - k:
            q.popleft()

        while q and arr[q[-1]] <= arr[i - 1]:
            q.pop()
           
        q.append(i - 1)

        for j in range(max(0, i - k), i):
            dp[i] = min(dp[i], dp[j] + arr[q[0]])

    return dp[n]


print(func())

Server system vulnerabilities โœ…
Source : jogi
int solve(ll n){
  
 
  ll i;

 
  ll a = 0;
  ll b = 1;

  for (i = 2; i <= n; i++)
  {
     
      ll c = a+b;
      a=b;
      b=c;
  }

  return (2*b)%mod;
}
Lucky Strings โœ…
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>>points(n);
    for(int i=0;i<n;i++){
        cin>>points[i].first>>points[i].second;
    }
    int k;
    cin>>k;
    vector<pair<double,int>>store;
    for(int i=0;i<n;i++){
        double dist=pow((pow(points[i].first,2)+pow(points[i].second,2)),0.5);
        store.push_back({dist,i});
    }
    sort(store.begin(),store.end());
    for(int i=0;i<k;i++){
        int index=store[i].second;
        cout<<points[index].first<<" "<<points[index].second<<endl;
    }
    return 0;
}

At Center โœ…
Walmart
#include <bits/stdc++.h> 
using namespace std; 
#define int long long 
 
int n; 
int t[21][10003]; 
 
int solve(vector<int>& rods, int i, int diff) { 
    if (i == n) { 
        if (diff == 0) 
            return 0; 
 
        return LLONG_MIN;   
    } 
 
    if (t[i][diff + 5000] != -1) 
        return t[i][diff + 5000]; 
 
    int ans = 0; 
 
    int nothing = solve(rods, i + 1, diff); 
    int in_rod_1 = rods[i] + solve(rods, i + 1, diff + rods[i]); 
    int not_in_rod1 = rods[i] + solve(rods, i + 1, diff - rods[i]); 
 
    return t[i][diff + 5000] = max({nothing, in_rod_1, not_in_rod1}); 

 
int check(vector<int>& rods) { 
    n = rods.size(); 
 
    memset(t, -1, sizeof(t)); 
 
    return solve(rods, 0, 0) / 2; 

 
signed main() { 
    int n; 
    cin >> n; 
    vector<int> rods(n); 
    for (int i = 0; i < n; ++i) 
        cin >> rods[i]; 
    cout << check(rods); 
 
    return 0; 
}

Maximum power โœ…
def max_difference(arr):
    n = len(arr)
    next_greater = [-1] * n
    stack = []

    for i in range(n):
        while stack and arr[i] > arr[stack[-1]]:
            next_greater[stack.pop()] = i

        stack.append(i)

    max_diff = float('-inf')

    for i in range(n):
        if next_greater[i] != -1:
            max_diff = max(max_diff, abs(arr[next_greater[i]] - arr[i]))

    return max_diff

Calculate Difference โœ