๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.53K 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(vector<int>& arr) {
    set<int> uniqueElements(arr.begin(), arr.end());
    long long sum = 0;

    for (int elem : uniqueElements) {
        sum += (1LL << elem);
    }

    cout << sum << endl;
}

int main() {
    vector<int> arr = {1, 2, 3, 2, 1};
    solve(arr);

    return 0;
}

Walmart โœ…
from collections import Counter

def get_max_common_str_len(strs):
    counters = [Counter(s) for s in strs]
    result = 0
    for i in range(26):
        letter = chr(ord("a") + i)
        freq = float("inf")
        for counter in counters:
            if counter[letter] < freq:
                freq = counter[letter]
        result += freq

    return result

Walmart โœ…
#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 โœ