๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
Swageazy is seeking a driven and enthusiastic Sr. Associate - Enterprise Sales.
Experience - Fresher ( who has recently graduated).

Job location - HSR, Bangalore
Salary - Up to 5.5 lpa

Interested candidates can share their resume on ankita@swageazy.com
vector<int> BobnBot(int N, int M, vector<vector<int>> games, int Q, vector<vector<int>> queries) {
    vector<int> result;
    for (const auto& query : queries) {
        vector<int> cleaned_query;
        for (int num : query) {
            if (num != -1) {
                cleaned_query.push_back(num);
            } else {
                break;
            }
        }
        int match_count = 0;
        for (const auto& game : games) {
            bool match = true;
            for (size_t i = 0; i < cleaned_query.size(); ++i) {
                if (game[i] != cleaned_query[i]) {
                    match = false;
                    break;
                }
            }
            if (match) {
                ++match_count;
            }
        }

        result.push_back(match_count);
    }

    return result;
}

The bot and the game โœ…
๐Ÿ‘1
vector<string> areAlmostEquivalent(vector<string>& s, vector<string>& t) {
    vector<string> result;
    auto countCharacters = [](const string& str) {
        vector<int> count(26, 0);
        for (char c : str) {
            count[c - 'a']++;
        }
        return count;
    };
    for (size_t i = 0; i < s.size(); ++i) {
        const string& str_s = s[i];
        const string& str_t = t[i];
  
        vector<int> count_s = countCharacters(str_s);
        vector<int> count_t = countCharacters(str_t);

        bool isAlmostEquivalent = true;
        for (int j = 0; j < 26; ++j) {
            if (abs(count_s[j] - count_t[j]) > 3) {
                isAlmostEquivalent = false;
                break;
            }
        }

        if (isAlmostEquivalent) {
            result.push_back("YES");
        } else {
            result.push_back("NO");
        }
    }
   
    return result;
}

Almost Equivalent strings โœ…
๐Ÿ‘1
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int minStones(vector<int>& xstart, vector<int>& xend) {
    int n = xstart.size();
    vector<pair<int, int>> intervals;
    for (int i = 0; i < n; ++i) {
        intervals.push_back({xend[i], xstart[i]});
    }
    sort(intervals.begin(), intervals.end());
    int stones = 0;
    int lastSmashed = -1;
    for (const auto& interval : intervals) {
        int start = interval.second;
        int end = interval.first;
       
        if (start > lastSmashed) {
            stones++;
            lastSmashed = end; 
        }
    }
    return stones;
}
๐Ÿ‘1๐Ÿคฎ1
Forwarded from Amazon Exam Placement Group (Dushyant)
Amazon Exam Placement Group
Photo
vector<int> suitableLocations(vector<int>& center, long d) {
    auto feasible = & {
        long total = 0;
        for (int point : center) {
            total += abs(mid - point) * 2;
        }
        return total <= d;
    };
    auto binarySearchRight = & {
        int low = start;
        int high = end;
        while (low <= high) {
            int mid = low + (high - low) / 2;
            if (feasible(mid)) {
                low = mid + 1;
            } else {
                high = mid - 1;
            }
        }
        return low - 1;
    };
    auto binarySearchLeft = & {
        int low = start;
        int high = end;
        while (low <= high) {
            int mid = low + (high - low) / 2;
            if (feasible(mid)) {
                high = mid - 1;
            } else {
                low = mid + 1;
            }
        }
        return low;
    };
    vector<int> suitablePoints;
    int rightLimit = binarySearchRight(0, *max_element(center.begin(), center.end()) + d);
    int leftLimit = binarySearchLeft(*min_element(center.begin(), center.end()) - d, -1);
    for (int i = leftLimit; i <= rightLimit; ++i) {
        suitablePoints.push_back(i);
    }
    return suitablePoints;
}

Amazon โœ…
๐Ÿ‘1
Forwarded from Amazon Exam Placement Group (Dushyant)
int totalDist(vector<int>& c, int x) {
    int d = 0;
    for (int i : c) d += 2 * abs(i - x);
    return d;
}

int suitableLocations(vector<int>& c, long long d) {
    sort(c.begin(), c.end());
    auto td = & { return totalDist(c, x); };
    int m = c.size() / 2, l = m, r = m;
    while (td(l) <= d) l -= 1;
    while (td(r) <= d) r += 1;
    return max(0, r - l - 1);
}

Amazon โœ