๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.59K subscribers
5.59K photos
3 videos
95 files
10.1K 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
Geek Countโœ…


const int MOD = 1000000007;

int countGeekSubsequences(const string& s) {
    int n = s.length();
    vector<vector<int>> dp(5, vector<int>(n + 1, 0));
    for (int i = 0; i < 5; ++i)
        dp[i][0] = 0;
    for (int i = 0; i <= n; ++i)
        dp[0][i] = 1;

    for (int i = 1; i <= 4; ++i) {
        for (int j = 1; j <= n; ++j) {
            dp[i][j] = dp[i][j - 1];
            if (s[j - 1] == "geek"[i - 1])
                dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % MOD;
        }
    }
    
    return dp[4][n];
}
๐Ÿ˜1
#include <vector>
#include <unordered_map>
#include <iostream>

using namespace std;

int getMinTransactions(int n, vector<vector<int>>& debt) {
    unordered_map<int, int> balance
    for (const auto& d : debt) {
        balance[d[0]] -= d[2];
        balance[d[1]] += d[2];
    }
   
    vector<int> transactions;
    for (const auto& entry : balance) {
        if (entry.second != 0) {
            transactions.push_back(entry.second);
        }
    }

    int count = 0;
    int i = 0, j = transactions.size() - 1;
    while (i < j) {
        if (transactions[i] + transactions[j] == 0) {
            count++;
            i++;
            j--;
        } else if (transactions[i] + transactions[j] > 0) {
            transactions[i] += transactions[j];
            j--;
            count++;
        } else {
            transactions[j] += transactions[i];
            i++;
            count++;
        }
    }
    return count;
}

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

#define ll long long
#define maxn 1000005
#define inf 1e9

string ff(ll a, ll b, ll c, ll d) {
    ll kit = (b - a + 1) * (d - c + 1);
    ll kat = (b - a + 1) * (d - c);
    return (kat > kit / 2) ? "YES" : "NO";
}

int main() {
    ll a, b, c, d;
    cin >> a >> b;
    cin >> c >> d;
    cout << ff(a, b, c, d) << endl;
    return 0;
}

Guess the full form โœ…
Flipkart
def probability_comparison(L1, R1, L2, R2):
    alice_wins = 0
    for i in range(L1, R1+1):
        for j in range(L2, R2+1):
            if i > j:
                alice_wins += 1
   
    total_outcomes = (R1 - L1 + 1) * (R2 - L2 + 1)
   
    if alice_wins > total_outcomes / 2:
        return "YES"
    else:
        return "NO"
L1, R1, L2, R2 = map(int, input().split())
print(probability_comparison(L1, R1, L2, R2))

Prediction โœ…
def final_card_person(N, K, A):
    remainder = K % N
    final_position = (A - 1 + remainder) % N
    if final_position == 0:
        final_position = N
    return final_position

Cards and Party โœ…
def decode_secret_code(S, N):
    if N == 1:
        return S

    rows = [''] * N
    row = 0
    down = True
   
    for char in S:
        rows[row] += char
       
        if row == 0:
            down = True
        elif row == N - 1:
            down = False
           
        if down:
            row += 1
        else:
            row -= 1

    secret_code = ''.join(rows)
    return secret_code

S = input()
N = int(input())
result = decode_secret_code(S, N)
print(result)

Flipkart โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
def decode_secret_code(S, N):     if N == 1:         return S     rows = [''] * N     row = 0     down = True         for char in S:         rows[row] += char                 if row == 0:             down = True         elif row == N - 1:             downโ€ฆ
#include <iostream>
#include <vector>

using namespace std;

string findPassword(string s, int n) {
    if (n == 1)
        return s;

    vector<vector<char>> zigzag(n, vector<char>());
    bool down = true;
    int row = 0;

    for (char c : s) {
        zigzag[row].push_back(c);

        if (down)
            row++;
        else
            row--;

        if (row == 0 || row == n - 1)
            down = !down;
    }

    string password;
    for (int i = 0; i < n; i++) {
        for (char c : zigzag[i]) {
            password += c;
        }
    }

    return password;
}

int main() {
    string s;
    int n;

    cin >> s >> n;

   
    cout << findPassword(s, n) << endl;

    return 0;
}

Flipkartโœ…
๐Ÿ‘1
#include<bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> arr(n);
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    stack<int> s;
    vector<int> nwe(n, -1);
    for(int i = 0; i < n; i++) {
        while(!s.empty() && arr[s.top()] > arr[i]) {
            nwe[s.top()] = arr[i];
            s.pop();
        }
        s.push(i);
    }
    for(int i = 0; i < n; i++) {
        cout << nwe[i] << " ";
    }
    cout << endl;
    return 0;
}
#include <iostream>

using namespace std;

int maxChocolateCakes(int A, int P) {
    int totalPieces = A * 3 + P;
    return totalPieces / 2;
}

int main() {
    int A, P;
    cin >> A >> P;
   
    int maxCakes = maxChocolateCakes(A, P);
   
    cout << maxCakes << endl;
   
    return 0;
}

Chocoland โœ…
MOD = 998244353
def count_pairs(N):
    count = 0
    b = N
    for a in range(N + 1):
        while b > 0 and (a & b) > N:
            b -= 1
        count = (count + max(b - a + 1, 0)) % MOD
    return count
N = int(input())
print(count_pairs(N))

Flipkart โœ