๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.59K photos
3 videos
95 files
10.2K 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
def solution(a, b):
    def iDigit(s1, s2, i):
        d1 = int(s1[-i]) if i <= len(s1) else 0
        d2 = int(s2[-i]) if i <= len(s2) else 0
        return d1 + d2

    result = []
    maxL = max(len(a), len(b))
   
    for i in range(1, maxL + 1):
        result.append(str(iDigit(a, b, i)))
   
    return ''.join(result[::-1])


Visa โœ…
vector<int>solution(vector<vector<int>>lamps,vector<int>points)
{
    map<int,int>mp;
    for(auto &ele:lamps)
    {
        mp[ele[0]]++;
        mp[ele[1]+1]--;
    }
    map<int,int>temp;
    int ct=0;
    for(int i=1;i<=1e5+1;i++)
    {
        ct+=mp[i];
        temp[i]=ct;
    }
    vector<int>ans;
    for(int i=0;i<points.size();i++)
    {
        ans.push_back(temp[points[i]]);
    }
    return ans;
}


Visa โœ…
๐Ÿ”ฅ1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
vector<int>solution(vector<vector<int>>lamps,vector<int>points) {     map<int,int>mp;     for(auto &ele:lamps)     {         mp[ele[0]]++;         mp[ele[1]+1]--;     }     map<int,int>temp;     int ct=0;     for(int i=1;i<=1e5+1;i++)     {         ct+=mp[i];โ€ฆ
vector<int> solution(vector<vector<int>>& lamps, vector<int>& points) {
  
    vector<pair<int, int>> events;
    for (const auto& lamp : lamps) {
        events.push_back({lamp[0], 1}); 
        events.push_back({lamp[1] + 1, -1});
    }
   
   
    sort(events.begin(), events.end());
    vector<pair<int, int>> indexed_points;
    for (int i = 0; i < points.size(); ++i) {
        indexed_points.push_back({points[i], i});
    }
    sort(indexed_points.begin(), indexed_points.end());

    vector<int> result(points.size());
    int active_lamps = 0;
    int event_index = 0;

   
    for (const auto& [point, index] : indexed_points) {
        while (event_index < events.size() && events[event_index].first <= point) {
            active_lamps += events[event_index].second;
            ++event_index;
        }
        result[index] = active_lamps;
    }

    return result;
}


Visa โœ…
๐Ÿ”ฅ1
def Solve(N, K, A):
    remaining = list(range(1, N+1))
    time = 0
    i = 0
   
    while time < K and remaining:
        if A[remaining[i] - 1] > 0:
            A[remaining[i] - 1] -= 1
            time += 1
           
            if A[remaining[i] - 1] == 0:
                remaining.pop(i)
                i -= 1
       
        i = (i + 1) % len(remaining) if remaining else 0
   
    return remaining if remaining else [-1]

Egynte 2
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
int getMaximumDistance(vector<int> location, int k)
{
    int n = location.size();
    sort(location.begin(), location.end());

    int maxi = location[n - 1] - location[0];

    int left = 0, right = maxi;
    while (left < right)
    {
        int mid = left + (right - left) / 2;
        int center = 1;
        int prev = location[0];
        for (int i = 1; i < n; i++)
        {
            if (location[i] - prev > mid * 2)
            {
                center++;
                prev = location[i];
            }
        }

        if (center <= k)
        {
            right = mid;
        }
        else
        {
            left = mid + 1;
        }
    }

    return left;
}
๐Ÿ‘1