๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
int findMaximumGreatness( vector<int>&arr) {
    int n = arr.size()
    vector<int>v = arr;
    sort(begin(v), end(v));
    sort(begin(arr), end(arr));
    int ans = 0;
    int i = n - 1, j = n - 1;
    while (i >= 0 && j >= 0) {
        if (v[i] > arr[j]) {
            ans++;
            i--;
            j--;
        }
        else {
            j--;
        }
    }
    return ans;
}

UKG โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
const int MOD = 1000000007;
using namespace std;
void dfs(int node, const unordered_map<int, vector<pair<int, int>>>& tree, vector<long long>& magnitudes) {
    auto it = tree.find(node);
    if (it != tree.end()) {
        for (const auto& neighbor : it->second) {
            int next_node = neighbor.first;
            int weight = neighbor.second;
            magnitudes[next_node] = (magnitudes[node] * weight) % MOD;
            dfs(next_node, tree, magnitudes);
        }
    }
}

vector<int> findEquivalentMagnitude(int unit_nodes, vector<int> unit_from, vector<int> unit_to, vector<int> unit_weight, int x) {
    unordered_map<int, vector<pair<int, int>>> tree;
    for (int i = 0; i < unit_from.size(); ++i) {
        tree[unit_from[i]].emplace_back(unit_to[i], unit_weight[i]);
    }
    vector<long long> magnitudes(unit_nodes + 1, -1);
    magnitudes[1] = x;

    dfs(1, tree, magnitudes);

    vector<int> result(unit_nodes);
    for (int i = 1; i <= unit_nodes; ++i) {
        result[i - 1] = magnitudes[i];
    }

    return result;
}

UKGโœ…
๐Ÿ‘1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
public static int countMeetings(int[] firstDay, int[] lastDay) {
        int n = firstDay.length;
        TreeSet<Integer> availableDays = new TreeSet<>();
        for (int i = 1; i <= 100000; i++) {
            availableDays.add(i);
        }
       
        int count = 0;
        for (int i = 0; i < n; i++) {
            int start = firstDay[i];
            int end = lastDay[i];
            Integer day = availableDays.ceiling(start);
            if (day != null && day <= end) {
                count++;
                availableDays.remove(day);
            }
        }
       
        return count;
    }

Standard chartered โœ…
class Investment:
    @staticmethod
    def times_of_investment(input1, input2):
        A = sum(input2)
        Res = 0
        while A % 2 == 0 and A != 0:
            A //= 2
            Res += 1
        return Res


Profit Group
OLAโœ…
๐Ÿ‘1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
int mrt2(const string& st) {
    int n = st.length();
    vector<vector<int>> lst(n, vector<int>(n, 0));
    for (int i = 0; i < n; ++i)
        lst[i][i] = 1;

    for (int k = 2; k <= n; ++k) {
        for (int i = 0; i <= n - k; ++i) {
            int j = i + k - 1;
            if (st[i] == st[j]) {
                if (k == 2)
                    lst[i][j] = 2;
                else
                    lst[i][j] = lst[i + 1][j - 1] + 2;
            } else {
                lst[i][j] = max(lst[i + 1][j], lst[i][j - 1]);
            }
        }
    }
    return lst[0][n - 1];
}

int delete_op(const string& st) {
    int n = st.length();
    int lps = mrt2(st);
    return n - lps;
}

bool rearrange(const string& S) {
    unordered_map<char, int> freq;
    for (char c : S) {
        freq[c]++;
    }

    int odd_count = 0;
    for (auto& p : freq) {
        if (p.second % 2 == 1)
            odd_count++;
    }

    return odd_count <= 1;
}

vector<int> mrt(const string& S, const vector<pair<int, int>>& arr) {
    vector<int> res;
    for (auto& range : arr) {
        string temp = S.substr(range.first - 1, range.second - range.first + 1);
        int result = rearrange(temp) ? 0 : delete_op(temp);
        res.push_back(result);
    }
    return res;
}


String and queries
OLAโœ…
๐Ÿ‘1
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int minimizeDiff(int a, vector<int>& b) {
    int c = b.size();
    int d = *max_element(b.begin(), b.end());
    int e = *min_element(b.begin(), b.end());
    if ((d - e) <= a) {
        return (d - e);
    }
    int f = (d + e) / 2;
    for (int g = 0; g < c; g++) {
        if (b[g] > f) {
            b[g] -= a;
        } else {
            b[g] += a;
        }
    }
    d = *max_element(b.begin(), b.end());
    e = *min_element(b.begin(), b.end());
    return (d - e);
}


ICE CREAM Sticks โœ…
Intuit