๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.57K subscribers
5.58K photos
3 videos
95 files
9.93K 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
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 โœ…
๐Ÿ‘2
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.
๐Ÿ‘1
#include <bits/stdc++.h>
using namespace std;

int main() {
    int a; // towerHeight
    cin >> a;

    int arr1[5]; // blockHeights
    for (int &height : arr1) {
        cin >> height;
    }

    sort(arr1, arr1 + 5, greater<int>());

    int arr2[10001]; // maxBlocks, assuming the tower height does not exceed 10000
    memset(arr2, -1, sizeof(arr2));
    arr2[0] = 0;

    for (int b = 1; b <= a; ++b) {
        for (int c : arr1) {
            if (b - c >= 0 && arr2[b - c] != -1) {
                arr2[b] = max(arr2[b], arr2[b - c] + 1);
            }
        }
    }

    if (arr2[a] == -1) {
        cout << "Impossible";
        return 0;
    }

    map<int, int> arr3; // blockUsage
    while (a > 0) {
        for (int c : arr1) {
            if (a - c >= 0 && arr2[a] == arr2[a - c] + 1) {
                arr3[c]++;
                a -= c;
                break;
            }
        }
    }

    vector<pair<int, int>> arr4(arr3.begin(), arr3.end()); // usedBlocks
    sort(arr4.begin(), arr4.end(), [](const pair<int, int>& d, const pair<int, int>& e) {
        return d.second == e.second ? d.first < e.first : d.second > e.second;
    });

    for (size_t i = 0; i < arr4.size(); ++i) {
        cout << arr4[i].first;
        if (i < arr4.size() - 1) {
            cout << " ";
        }
    }

    return 0;
}


//Credits - AB



//Christmas Tower
//Codevita
๐Ÿ‘1
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 โœ