๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
using namespace std;
void aa(vector<vector<char>>& board) {
    int rows = board.size();
    int cols = board[0].size();
    for (int i = 0; i < rows; ++i) {
        int rightmost = cols - 1;
        for (int j = cols - 1; j >= 0; --j) {
            if (board[i][j] == '*') {
                rightmost = j - 1;
            } else if (board[i][j] == '#') {
                if (j != rightmost) {
                    board[i][rightmost] = '#';
                    board[i][j] = '-';
                }
                rightmost--;
            }
        }
    }
}

void bb(vector<vector<char>>& board) {
    int rows = board.size();
    int cols = board[0].size();

    for (int j = 0; j < cols; ++j) {
        int bottommost = rows - 1;
        for (int i = rows - 1; i >= 0; --i) {
            if (board[i][j] == '*') {
                bottommost = i - 1;
            } else if (board[i][j] == '#') {
                if (i != bottommost) {
                    board[bottommost][j] = '#';
                    board[i][j] = '-';
                }
                bottommost--;
            }
        }
    }
}
void pushBoxes(vector<vector<char>>& board) {
    aa(board);
    bb(board);
}


Databrick โœ…
๐Ÿ‘1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
using namespace std;
int solve(long numberToFind) {
    if (numberToFind <= 0) {
        return 0;
    }
    int cnt = 0;
    bool done = false;
    for (int i = 0; i < 33; ++i) {
        if (numberToFind < pow(2, i)) {
            long result = 0;
            long previous = 0;
            for (int j = i - 1; j >= 0; --j) {
                result = numberToFind - previous - pow(2, j);
                if (result == 0) {
                    cnt++;
                    done = true;
                    break;
                }
                if (result == 1) {
                    cnt += 2;
                    done = true;
                    break;
                }
                if (result > 0) {
                    cnt++;
                    previous += pow(2, j);
                }
                if (j == 0) {
                    done = true;
                    break;
                }
            }
        }
        if (done) {
            break;
        }
    }

    return cnt % 3;
}


BlackRock โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
def findNthDigit(n):
    length = 1
    while length <= n:
        length *= 2
   
    def gd(index, length):
        if length == 1:
            return '0'
       
        hl = length // 2
        if index < hl:
            return gd(index, hl)
        else:
            si = index - hl
            bd = gd(si, hl)
            if bd == '0':
                return '1'
            elif bd == '1':
                return '2'
            else:
                return '0'

    return int(gd(n, length))
def r():
    import sys
    i = sys.stdin.read
    d = i().strip().split('\n')
    s1 = set(d[0].split())
    s2 = set(d[1].split())
    return s1, s2
def f(s1, s2):
    c = s1.intersection(s2)
    s_c = sorted(c, key=lambda x: (x.isalpha(), x))
    r = ' '.join(s_c)
    return r if r else "NULL"
def m():
    s1, s2 = r()
    print(f(s1, s2))
if name == "main":
    m()

BlackRock
Alphanumeric characters โœ…
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int T = scanner.nextInt();

        while (T-- > 0) {
            int N = scanner.nextInt();
            int[][] traps = new int[N][N];
            int[][] dp = new int[N][N];

            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    traps[i][j] = scanner.nextInt();
                }
            }

            for (int j = 0; j < N; j++) {
                dp[0][j] = traps[0][j];
            }

            for (int i = 1; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    int minPath = dp[i - 1][j];
                    if (j > 0) {
                        minPath = Math.min(minPath, dp[i - 1][j - 1]);
                    }
                    if (j < N - 1) {
                        minPath = Math.min(minPath, dp[i - 1][j + 1]);
                    }
                    dp[i][j] = traps[i][j] + minPath;
                }
            }

            int minSum = dp[N - 1][0];
            for (int j = 1; j < N; j++) {
                minSum = Math.min(minSum, dp[N - 1][j]);
            }


            System.out.println(minSum);
        }

        scanner.close();
    }
}


//unify apps treasure hunt
#include <bits/stdc++.h>
using namespace std;
int solve(int N, int K, const vector<int>& G, const vector<int>& P) {
    vector<int> dp(K + 1, 0);
    for (int i = 0; i < N; ++i) {
        int price = P[i];
        int dd = G[i];
                for (int j = K; j >= price; --j) {
            dp[j] = max(dp[j], dp[j - price] + dd);
        }
    }
   
    return dp[K];
}


Shopping Spree
Delta X โœ…
โค1
def canReach(x1, y1, x2, y2):
    while x1 < x2 and y1 < y2:
        if x2 > y2:
            x2 -= y2
        else:
            y2 -= x2
   
    return (x1 == x2 and y1 <= y2 and (y2 - y1) % x1 == 0) or \
           (y1 == y2 and x1 <= x2 and (x2 - x1) % y1 == 0)


Expedia โœ…
๐Ÿ‘1
long long cal(vector<int>&arr, long long val)
{
  long long n = arr.size();
  vector<long long>diff;
  for (auto it : arr) {
    long long dif = val - it;
    if (dif != 0) {
      diff.push_back(dif);
    }
  }
  long long cnttwo = 0;
  for (long long i = 0; i < diff.size(); ++i)
  {
    cnttwo += (diff[i] / 2);
    diff[i] %= 2;
  }

  long long cntone = 0;
  for (long long i = 0; i < diff.size(); ++i)
  {
    cntone += diff[i];
  }
  long long res = max(cntone * 2 - 1, cnttwo * 2);
  while (cnttwo > 0 && cntone  < cnttwo ) {
    cnttwo -= 1;
    cntone += 2;
    res = min(res, max(cntone * 2 - 1, cnttwo * 2));
  }
  res = min(res, max(cntone * 2 - 1, cnttwo * 2));
  return res;
}

long long findMinGeneration(vector<int>layer)
{
  long long n = layer.size();
  long long mx = *max_element(layer.begin(), layer.end());

  long long val1 = cal(layer, mx);
  long long val2 = cal(layer, mx + 1);
  long long val3 = cal(layer, mx + 2);
  long long res = min({val1, val2, val3});
  return res;
}
FINDGENERATIONS UBS 13/15 :)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int M=998244353;
ll modx(ll x){
return ((x%M + M)%M);
}
ll add(ll a, ll b){
return modx(modx(a)+modx(b));
}
ll mul(ll a, ll b){
return modx(modx(a)*modx(b));
}

ll modPow(ll a, ll b){
    if(b==0)
    return 1LL;
    if(b==1)
    return a%M;
    ll res=1;
    while(b){
        if(b%2==1)
         res=mul(res,a);
         a=mul(a,a);
         b=b/2;
        }
    return res;
}
int main()
{

int n;
cin>>n;
vector<int>v(n);
map<ll,ll>mpp;
map<ll,ll>freq;
for(int i = 0;i<n;i++){
    cin>>v[i];
    freq[v[i]]++;
}

ll m = 1;
ll a = 0;
for(int i = 0;i<=n;i++){
   
    a = add(a,freq[0]);
    ll y = modPow(2,n-a);
    ll mex = mul(m,y);
    mpp[i] = mex;
    m = mul(m,(modPow(2,freq[i])-1));
}
  
int l,r;
cin>>l>>r;

if(l>n){
    cout<<0<<endl;
    return 0;
}
else if(r>n){
   r = n;
}

int s = 0;
for(int i = l;i<=r;i++) s+=mpp[i];
cout<<s<<endl;
return 0;
}


countsubsequences 
UBS โœ…
def conversionPermutation(n):
    if n == 0:
        return "0"

    min_rep = None
    digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"

    for b in range(2, min(n + 1, 37)):
        rep = ""
        temp = n
        while temp > 0:
            rep = digits[temp % b] + rep
            temp //= b
       
        if min_rep is None or rep < min_rep:
            min_rep = rep

    return min_rep


Conversion Permutation โœ…
๐Ÿ‘1