๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
#include<bits/stdc++.h>
using namespace std;

void solve(string acc, int b, int c, int a, int n) {
    if(acc.size() == n) {
        cout << acc << endl;
        return;
    }
    if(b > 0) solve(acc + 'B', b - 1, c, a, n);
    if(c > 0) solve(acc + 'C', b, c - 1, a, n);
    if(a > 0) solve(acc + 'A', b, c, a - 1, n);
}

int main() {
    int n, b, c, a;
    cin >> n >> b >> c >> a;
    solve("", b, c, a, n);
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> ng(n, -1), mr(n);
    stack<int> s;
    for(int i = n - 1; i >= 0; i--) {
        while(!s.empty() && s.top() <= a[i]) {
            s.pop();
        }
        if(!s.empty()) {
            ng[i] = s.top();
        }
        s.push(a[i]);
        mr[i] = i == n - 1 ? a[i] : max(a[i], mr[i + 1]);
    }
    int md = 0;
    for(int i = 0; i < n; i++) {
        if(ng[i] != -1) {
            md = max(md, abs(ng[i] - mr[i]));
        }
    }
    cout << md << endl;
    return 0;
}

Walmart โœ…
long long countSubarrays(vector<int>& nums, int minK, int maxK) {
        long long int ans = 0;
        int temp=-1,mini=-1,maxi=-1,n=nums.size();
        for(int i=0;i<n;i++){
            if(nums[i]<minK || nums[i]>maxK) temp=i;
            if(nums[i]==minK) mini=i;
            if(nums[i]==maxK) maxi=i;            ans+=max(0,min(mini,maxi)-temp);
        }
        return ans;
    }
Do you enjoy reading this channel?

Perhaps you have thought about placing ads on it?

To do this, follow three simple steps:

1) Sign up: https://telega.io/c/cs_algo
2) Top up the balance in a convenient way
3) Create an advertising post

If the topic of your post fits our channel, we will publish it with pleasure.
def getSubsequenceCount(s1, s2):
    def count_subsequences(s1, s2, index1, index2):
        if index1 == 3:
            return 1
        if index2 == len(s2):
            return 0

        count = count_subsequences(s1, s2, index1, index2 + 1)

        if s1[index1] == s2[index2]:
            count += count_subsequences(s1, s2, index1 + 1, index2 + 1)

        return count

    return count_subsequences(s1, s2, 0, 0)

Meesho โœ…
def maximum_learning(iv, articles, p):
    size = len(articles)
    art = [x * 2 for x in articles]
    ivs = iv

    return knap_sack_top_down(ivs, art, p, size)

def knap_sack_top_down(val, wt, W, n):
    mat = [[0] * (W + 1) for _ in range(n + 1)]

    for i in range(1, n + 1):
        for j in range(1, W + 1):
            if i == 0 or j == 0:
                mat[i][j] = 0
            elif wt[i - 1] <= j:
                mat[i][j] = max(val[i - 1] + mat[i - 1][j - wt[i - 1]], mat[i - 1][j])
            else:
                mat[i][j] = mat[i - 1][j]

    return mat[n][W]

Meesho โœ…
import heapq
def getSeatsAllocation(arr):
    n = len(arr)
    ppl = [[] for i in range(2 * n + 4)]
   
    for i, x in enumerate(arr):
        ppl[x].append(i)

    h = []
    ans = [-1] * n
   
    for pos in range(1, 2 * n + 1):
        for i in ppl[pos]:
            heapq.heappush(h, (-pos, i))
       
        if len(h) > 0:
            ans[heapq.heappop(h)[1]] = pos
   
    return ans

Meesho โœ…
def max_tie_moments(n, moments):
    max_tie_count = 0
    current_difference = 0

    for moment in moments:
        bob_goals, noddy_goals = moment
        difference = bob_goals - noddy_goals
        if difference == current_difference:
            max_tie_count += 1
        elif difference > current_difference:
            current_difference = difference
            max_tie_count = 0 

    return max_tie_count