๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> ratings(n);
    for (int i = 0; i < n; ++i) {
        cin >> ratings[i];
    }

    sort(ratings.begin(), ratings.end());

    vector<int> dp(n + 1, 0);
    int maxPlayers = 0;
    vector<vector<int>> dp2(m + 1, vector<int>(n + 1, 0));

    for (int i = 1; i <= m; ++i) {
        int left = 0;
        for (int right = 1; right <= n; ++right) {
            while (ratings[right - 1] - ratings[left] > 5) {
                ++left;
            }
            dp2[i][right] = max(dp2[i][right - 1], dp2[i - 1][left] + (right - left));
            maxPlayers = max(maxPlayers, dp2[i][right]);
        }
    }

    cout << maxPlayers << endl;

    return 0;
}

Uber โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
public int minChargingSpeed(int[] evBatteries, int totalHours) {
        int left = 1;
        int right = getMax(evBatteries);
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (canChargeAll(evBatteries, mid, totalHours)) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return left;
    }

    private int getMax(int[] evBatteries) {
        int max = 0;
        for (int battery : evBatteries) {
            max = Math.max(max, battery);
        }
        return max;
    }

    private boolean canChargeAll(int[] evBatteries, int speed, int totalHours) {
        int hoursNeeded = 0;
        for (int battery : evBatteries) {
            hoursNeeded += (battery + speed - 1) / speed;
        }
        return hoursNeeded <= totalHours;
    }

Uber โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include<bits/stdc++.h>
using namespace std;

vector<vector<int> > SolveTower (int N, vector<int> a) {
   // Write your code here
   vector<vector<int> > ans;
   int done = N;
   priority_queue<int> pq;
   for(auto x: a){
      pq.push(x);
      vector<int> aux;
      while(!pq.empty() && pq.top() == done){
         aux.push_back(done);
         pq.pop();
         done--;
      }
      ans.push_back(aux);
   }
   sort(a.begin(), a.end());
   a.resize(unique(a.begin(), a.end()) - a.begin());
   assert(a.size() == N);
   return ans;
}

int main() {

    ios::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    assert(1 <= N && N <= 1e6);
    vector<int> a(N);
    for(int i_a = 0; i_a < N; i_a++)
    {
     cin >> a[i_a];
    }

    vector<vector<int> > out_;
    out_ = SolveTower(N, a);
    for(int i = 0; i < out_.size(); i++){
       for(int j = 0; j < out_[i].size(); j++){
          cout << out_[i][j] << " ";
       }
       cout << "\n";
    }
}

Uber โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
public static String maskSensitiveInfo(String data) {
        if (isEmail(data)) {
            return maskEmail(data);
        } else if (isPhoneNumber(data)) {
            return maskPhoneNumber(data);
        }
        return data;
    }

    private static boolean isEmail(String data) {
        return data.matches("^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$");
    }

    private static boolean isPhoneNumber(String data) {
        return data.matches("^[0-9().\\-+ ]{10,20}$");
    }

    private static String maskEmail(String email) {
        email = email.toLowerCase();
        String[] parts = email.split("@");
        String local = parts[0];
        String domain = parts[1];

        if (local.length() > 2) {
            local = local.charAt(0) + "*" + local.charAt(local.length() - 1);
        } else {
            local = local.charAt(0) + "*";
        }
        return local + "@" + domain;
    }

    private static String maskPhoneNumber(String phone) {
        phone = phone.replaceAll("[^0-9]", "");
        int len = phone.length();
        String maskedPhone = "";

        if (len == 10) {
            maskedPhone = "###-###-" + phone.substring(6);
        } else if (len == 11) {
            maskedPhone = "+#-###-###-" + phone.substring(7);
        } else if (len == 12) {
            maskedPhone = "+##-###-###-" + phone.substring(8);
        } else if (len == 13) {
            maskedPhone = "+###-###-###-" + phone.substring(9);
        }

        return maskedPhone;
    }

Protecting Personal Information โœ…
int solve(int n)
{
    int ans = 0;
    for (int i = 1; i <= n; i *= 10)
    {
        int divider = i * 10;
        ans += (n / divider) * i +
               min(max(n % divider - i + 1, 0LL), i);
    }
    return ans;
}
int solve(vector<int> pass,int limit){
    sort(pass.begin(),pass.end());
   
    int ini=0;
    int fin=pass.size()-1;
    int count=0;
    while(ini<=fin){
        if(pass[ini]+pass[fin]<=limit){
            count++;
            ini++;
            fin--;
        }
        else{
            count++;
            fin--;
        }
    }
    return count;
}
๐Ÿ‘1
def solution(lamps):
    from collections import defaultdict
    illumination_count = defaultdict(int)
    for lamp in lamps:
        coord, radius = lamp
        for i in range(coord - radius, coord + radius + 1):
            illumination_count[i] += 1
    unique_illumination_count = sum(1 for count in illumination_count.values() if count == 1)
    return unique_illumination_count
We are inviting applications at GENPACT for the role of Management Trainee.

Skill Set : Record to Report, RTR, R2R.

โ€ข Location : Hyderabad
โ€ข Shifts : US
โ€ข Eligibility Criteria :
โ€ข CA (2024 batch) Freshers.
โ€ข Notice period : IMMEDIATE JOINERS, 30 Days.

Interested candidates can share their updated CV to me at diksha.prakash@genpact.com

โ€ข Full name :
โ€ข Current Profile :
โ€ข Current Company :
โ€ข Current designation :
โ€ข Current CTC :
โ€ข Expected CTC :
โ€ข Current location :
โ€ข Notice period :