๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.59K photos
3 videos
95 files
10.2K 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 <bits/stdc++.h>
  using namespace std;

  #define int long long
 
  vector<pair<int,int>> v;
  int dp[1005][1005];
  int solve(int i,int alice,int bob){
    if(i==v.size()) return 0;
   
    if(dp[alice][bob]!=-1) return dp[alice][bob];
   
    int v1=abs(v[alice].first-v[i].first) + abs(v[alice].second-v[i].second);
    int v2=abs(v[bob].first-v[i].first) + abs(v[bob].second-v[i].second);
   
    int al=v1 + solve(i+1,i,bob);
    int bb=v2 + solve(i+1,alice,i);
   
    return dp[alice][bob]=min(al,bb);
  }
 
  signed main() {
    int n;
    cin>>n;
   
    v.resize(n+2);
   
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n+2;i++){
      cin>>v[i].first>>v[i].second;
    }
   
    cout<<solve(2,0,1);

    return 0;

  }

Falling Apples โœ…
๐Ÿ‘1
int solve(vector<int> &a){
    vector<int> xorr(128, -1);
    xorr[0] = 0;

    for(auto i: a){
        for(int v=0; v<128; v++){
            if(xorr[v]!=-1){
                if(xorr[v]<i and builtin_popcount(v)<=builtin_popcount(i)){
                    int newx = v^i;
                    if(xorr[newx]==-1) xorr[newx] = i;
                    else xorr[newx] = min(i, xorr[newx]);
                }
            }
        }
    }

    int cnt = 0;
    for(auto i: xorr){
        if(i!=-1) cnt++;
    }
    return cnt;
}

Media net xor subsequence โœ…
Walmart Converge Sparkathon

Chance to interview at Walmart for Software Engineering Internships and Full Time roles with a package of 23 LPA and a stipend of 1 Lakh/month.

Open to all engineering colleges in India who are pursuing the following degrees in circuit branches (ECE, EE, EEE, IT, CS):

BE/B.Tech - Batch of 2024 and 2025 (1st and 2nd-year students are not eligible to apply)

Dual degree full-time program - Batch of 2024 and 2025 (1st/2nd/3rd-year students are not eligible to apply)

ME/M.Tech. full-time programs - Batch of 2024 (1st-year students are not eligible to apply)

Apply Link: https://walmart.converge.tech/content/converge/en_in/sparkathon.html
int solution(vector<int> arg1) {
    int n = arg1.size();
    int currentReach = 0;
    int maxReach = 0;
    int jumps = 0;

    for (int i = 0; i < n - 1; i++) {
        maxReach = max(maxReach, i + arg1[i]);
        if (i == currentReach) {
            currentReach = maxReach;
            jumps++;
        }
    }

    return jumps;
}
def countWays(k: int, n: int) -> int:
    MOD = 10**9 + 7
    dp = [[0 for _ in range(n + 1)] for __ in range(k + 1)]
    dp[1] = [0] + [1] * n
    for i in range(2, k + 1):
        total = sum(dp[i - 1])
        for j in range(1, n + 1):
            dp[i][j] = (total - dp[i - 1][j]) % MOD
return sum(dp[k]) % MOD


DTCC | Python โœ…
public class Solution {
    public static int getMaxLength(List<Integer> list) {
        int n = list.size();

        int[] freq = new int[32];
        for (int num : list) {
            for (int bit = 0; bit < 32; bit++) {
                if ((num & (1 << bit)) != 0) {
                    freq[bit]++;
                }
            }
        }

        int maxLen = 0;
        for (int i = 0; i < 32; i++) {
            maxLen = Math.max(maxLen, freq[i]);
        }

        return maxLen;
    }
}

Hackerrank
subsequence Length  โœ…
#include<bits/stdc++.h>
using namespace std;

int F(int x){
    int sum = 0;
    while(x){
        sum += x%10;
        x /= 10;
    }
    return sum;
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int max_x = max(b, c) * pow(9, a) + c;
    int max_digits = floor(log10(max_x) + 1);
    int max_Fx = 9 * max_digits;

    vector<int> solutions;
    for(int sum = 1; sum <= max_Fx; sum++){
        int x = b * pow(sum, a) + c;
        if(x <= max_x && sum == F(x)){
            solutions.push_back(x);
        }
    }

    cout << solutions.size() << endl;
    for(int x : solutions){
        cout << x << " ";
    }
    cout << endl;
    return 0;
}

Jaguar โœ