๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
Calling all 2023 and 2024 graduates!

Are you ready to make your mark in the world of ReactJS and React Native? Look no further!

Join us at the Appinventiv Mohali Office for an exclusive drive!

Drive Date: 26th July, Friday Time: 10:30 AM - 5:30 PM Venue: Appinventiv, Mohali

Office Don't miss out on this fantastic opportunity! Register now and take the first step towards an incredible career with Appinventiv - https://lnkd.in/gPWYsuxX
const int MOD = 1'000'000'007;

int countBalancedWords(int n, int d) {

    vector<vector<int>> dp(n + 1, vector<int>(26, 0));

    for (int j = 0; j < 26; ++j) {
        dp[1][j] = 1;
    }

    for (int i = 2; i <= n; ++i) {
        for (int j = 0; j < 26; ++j) {
            for (int k = 0; k < 26; ++k) {
                if (abs(j - k) <= d) {
                    dp[i][j] = (dp[i][j] + dp[i - 1][k]) % MOD;
                }
            }
        }
    }

    int result = 0;
    for (int j = 0; j < 26; ++j) {
        result = (result + dp[n][j]) % MOD;
    }
   
    return result;
}
๐Ÿ‘1
def min_swaps(s, k):
    k_count = s.count(k)
    if k_count <= 1:
        return 0

    window_size = k_count
    non_k_count = 0
   
    for i in range(window_size):
        if s[i] != k:
            non_k_count += 1
   
    min_swaps = non_k_count
   
    for i in range(window_size, len(s)):
        if s[i - window_size] != k:
            non_k_count -= 1
        if s[i] != k:
            non_k_count += 1
        min_swaps = min(min_swaps, non_k_count)
   
    return min_swaps
def max_errors_in_window(N, error_counts, K):
    if K > N:
        return max(error_counts)

    window_sum = sum(error_counts[:K])
    max_errors = window_sum
   
    for i in range(K, N):
        window_sum = window_sum - error_counts[i-K] + error_counts[i]
        max_errors = max(max_errors, window_sum)
   
    return max_errors

N = int(input())
error_counts = [int(input()) for _ in range(N)]
K = int(input())

result = max_errors_in_window(N, error_counts, K)
print(result)
def find_index_pairs(arr, k):
    n = len(arr)
    result = [0] * n
    value_dict = {}

    for i, value in enumerate(arr):
        if value in value_dict:
            if abs(i - value_dict[value]) == k:
                result[i] = 1
                result[value_dict[value]] = 1
        value_dict[value] = i

        target_plus = value + k
        target_minus = value - k
        if target_plus in value_dict and abs(i - value_dict[target_plus]) == k:
            result[i] = 1
            result[value_dict[target_plus]] = 1
        if target_minus in value_dict and abs(i - value_dict[target_minus]) == k:
            result[i] = 1
            result[value_dict[target_minus]] = 1

    return result

N = int(input())
arr = [int(input()) for _ in range(N)]
K = int(input())

output = find_index_pairs(arr, K)
for val in output:
    print(val)
#include <iostream>
#include <string>
#include <deque>
using namespace std;
int main() {
    string chocolates, choices;
    cin >> chocolates;
    cin >> choices;
    deque<char> stack(chocolates.begin(), chocolates.end());
    int redCount = 0;
    for (char choice : choices) {
        if (choice == 'F') {
            if (stack.front() == 'R') {
                redCount++;
            }
            stack.pop_front();
        } else if (choice == 'L') {
            if (stack.back() == 'R') {
                redCount++;
            }
            stack.pop_back();
        }
    }
    cout << redCount << endl;
    return 0;
}
๐Ÿ‘2