๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
int maxValidLength(const vector<int>& flowers, int K) {
    unordered_map<int, int> count;
    int n = flowers.size();
    int maxLength = 0;
    int left = 0;
    int distinctCount = 0;

    for (int right = 0; right < n; ++right) {
        if (count[flowers[right]] == 0) {
            distinctCount++;
        }
        count[flowers[right]]++;
                while (distinctCount == K) {
            count[flowers[left]]--;
            if (count[flowers[left]] == 0) {
                distinctCount--;
            }
            left++;
        }
       
        maxLength = max(maxLength, right - left + 1);
    }
   
    return maxLength;
}


Gardener and the flowers โœ…
Motorq
๐Ÿ‘1
SELECT
    department_id AS department_id,
    ROUND(AVG(salary), 2) AS avg_salary,
    COUNT(employee_id) AS num_employees
FROM
    employees
GROUP BY
    department_id
ORDER BY
    avg_salary DESC,
    department_id ASC;

Motorq โœ…
๐Ÿ‘1
void generateSubsequences(string s, string current, vector<string>& subsequences) {
    if (s.empty()) {
        if (!current.empty()) {
            subsequences.push_back(current);
        }
        return;
    }
   
    generateSubsequences(s.substr(1), current + s[0], subsequences);
    generateSubsequences(s.substr(1), current, subsequences);
}

vector<string> buildSubsequences(string s) {
    vector<string> subsequences;
    generateSubsequences(s, "", subsequences);
    sort(subsequences.begin(), subsequences.end());
    return subsequences;
}

Build the subsequence
ORACLEโœ…
from itertools import product
def goodOrBad(statementCounts, statements):
    n = len(statementCounts)
    max_good = 0
    for combination in product([True, False], repeat=n):
        is_valid = True
        good_count = sum(combination)
        for person, statement in statements:
            person -= 1
            if combination[person]:
                if not combination[statement - 1] == (statement == 1): 
                    is_valid = False
                    break
       
        if is_valid:
            max_good = max(max_good, good_count)
    return max_good


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

#define int long long

int solution(int n, vector<vector<int>>& edges) {
    vector<vector<int>> v(n + 1);
    vector<int> indegree(n + 1, 0);

    for (auto& edge : edges) {
        int u = edge[0], v1 = edge[1];
        v[u].push_back(v1);
        v[v1].push_back(u);
        indegree[v1]++;
        indegree[u]++;
    }

    vector<int> vis(n + 1, 0);
    queue<int> q;

    for (int i = 1; i <= n; i++) {
        if (indegree[i] == 1) {
            q.push(i);
            break;
        }
    }

    int c = 0;
    for (int i = 1; i <= n; i++) {
        if (indegree[i] == 0) {
            c++;
        }
    }

    if (q.empty()) {
        return -1;
    }

    while (!q.empty()) {
        int size = q.size();
        c++;
        for (int i = 0; i < size; i++) {
            auto node = q.front(); q.pop();
            if (vis[node]) continue;
            vis[node] = 1;

            for (auto x : v[node]) {
                if (!vis[x]) {
                    q.push(x);
                }
            }
        }
    }

    return c;
}
Cab Credit
Uber intern โœ…
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int min_sum_time(vector<int>& time) {
    sort(time.begin(), time.end());
    int total_time = 0;
    int current_sum = 0;
    for (int t : time) {
        current_sum += t;
        total_time += current_sum;
    }
    return total_time;
}

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

vector<vector<string>> solution(vector<string> apiList, vector<vector<long long>> rateLimits, vector<long long> defaultLimits, vector<vector<string>> requests) {
   
    struct RateLimit {
        long long limit;
        long long interval;
    };
   
    struct Request {
        string type;
        long long timestamp;
    };
   
    unordered_map<string, RateLimit> apiRateMap;
    for (size_t i = 0; i < apiList.size(); ++i) {
        apiRateMap[apiList[i]] = {rateLimits[i][0], rateLimits[i][1]};
    }


    unordered_map<string, queue<long long>> apiReqMap;
    unordered_map<string, long long> denied;

    for (const auto& req : requests) {
        string api = req[0];
        long long timestamp = stoll(req[1]);

        RateLimit rl = (apiRateMap.find(api) != apiRateMap.end()) ? apiRateMap[api] : RateLimit{defaultLimits[0], defaultLimits[1]};

        auto& q = apiReqMap[api];
       
        while (!q.empty() && q.front() <= timestamp - rl.interval) {
            q.pop();
        }

        if (q.size() < rl.limit) {
            q.push(timestamp);
        } else {
            denied[api]++;
        }
    }

    vector<vector<string>> result;
    for (const auto& entry : denied) {
        result.push_back({entry.first, to_string(entry.second)});
    }

    sort(result.begin(), result.end());
   
    return result;
}

Uber (intern) โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int min_time_to_enter_room(int n, vector<vector<int>>& entryTime) {
    vector<vector<int>> directions = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
    vector<vector<int>> earliest_time(n, vector<int>(n, INT_MAX));
    priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<>> pq;
    pq.push({0, {0, 0}});
    earliest_time[0][0] = 0;
   
    while (!pq.empty()) {
        int current_time = pq.top().first;
        int x = pq.top().second.first;
        int y = pq.top().second.second;
        pq.pop();
       
        if (x == n - 1 && y == n - 1) return current_time;
       
        for (auto& dir : directions) {
            int nx = x + dir[0];
            int ny = y + dir[1];
            if (nx >= 0 && ny >= 0 && nx < n && ny < n) {
                int next_time = max(current_time, entryTime[nx][ny]);
                if (next_time < earliest_time[nx][ny]) {
                    earliest_time[nx][ny] = next_time;
                    pq.push({next_time, {nx, ny}});
                }
            }
        }
    }
   
    return -1;
}
Uber (intern) โœ…
๐Ÿ‘1
Exciting Opportunity for freshers to Kickstart their Career โค๏ธโค๏ธโค๏ธ๐Ÿ’ฅ๐Ÿ’ฅ๐Ÿ’ฅ๐Ÿ’ช๐Ÿ’ช๐Ÿ’ช

Freshers WalkIn Alert ๐Ÿ”ฅ๐Ÿ”ฅ

Process- Back Office

Eligibility - Only Fresher/ Intern

Graduate- 2021 or above

Note- BE/B.Tech are not eligible.

Location: Gurgaon

Date of Interview: 23rd August, 2024.
Time: 10 AM

Address: 8th Floor, Big Audi, Tower C, Building 14, Sector 24 & 25 A, Gurugram- 122001.

Things to Carry:
Aadhaar Card
2 Copy of Resume

To confirm attendance, email
harmeet.2.singh@bt.com with "Yes, I will be coming" for prior security approval.
๐Ÿ‘2