๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
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 โ
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 โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
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) โ
#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
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Siemens is hiring Junior Rust Developer
For 2024, 2023 grads
https://jobs.siemens.com/careers/job/563156120514017?hl=en
For 2024, 2023 grads
https://jobs.siemens.com/careers/job/563156120514017?hl=en
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
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.
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
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Wipro Elite is hiring
Apply (if your college is eligible)
2023 & 2024 Batch students are eligible
Branch : BE/B.TECH/ME/M.TECH
Percentage criteria: 60% Throughout
Apply link :- https://app.joinsuperset.com/join/#/signup/student?jp=fd4be287-c8d5-4ace-ac26-6875ca63bc34
Apply (if your college is eligible)
2023 & 2024 Batch students are eligible
Branch : BE/B.TECH/ME/M.TECH
Percentage criteria: 60% Throughout
Apply link :- https://app.joinsuperset.com/join/#/signup/student?jp=fd4be287-c8d5-4ace-ac26-6875ca63bc34
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Metacube Software Pvt Ltd | Jaipur, Rajasthan
Eligibility Criteria (Minimum percentage)
Minimum 10th Percentage 70%
Minimum 12th Percentage 70%
Minimum College Percentage 65%
https://www.tpohub.com/#/student-drive/details/set-2024-08-23-jaipur-raj-job-off-metacube-software-engineer-trainee/1253
Eligibility Criteria (Minimum percentage)
Minimum 10th Percentage 70%
Minimum 12th Percentage 70%
Minimum College Percentage 65%
https://www.tpohub.com/#/student-drive/details/set-2024-08-23-jaipur-raj-job-off-metacube-software-engineer-trainee/1253
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Linkedin
Mohit G. on LinkedIn: #hiring #zepto #engineering #joinus | 62 comments
๐ Exciting Opportunities at Zepto! ๐
I am hiring for my team across below levels and roles :
SDE-1
SDE-2
SDE-3 ( SSE )
SDE-4 ( Tech Lead )
If youโreโฆ | 62 comments on LinkedIn
I am hiring for my team across below levels and roles :
SDE-1
SDE-2
SDE-3 ( SSE )
SDE-4 ( Tech Lead )
If youโreโฆ | 62 comments on LinkedIn
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include<climits>
using namespace std;
const int MOD = 1e9 + 7;
class Solution {
public:
int removeIntegers(int N, int P, int Q, vector<int>& special_integers) {
sort(special_integers.begin(), special_integers.end());
unordered_map<int, bool> is_special;
for (int num : special_integers)
is_special[num] = true;
return minCost(1, 1 << N, P, Q, is_special);
}
private:
int minCost(int start, int end, int P, int Q, unordered_map<int, bool>& is_special) {
int length = end - start + 1;
if (length == 1) {
return is_special[start] ? P : Q;
}
if (is_power_of_two(length)) {
return is_special[start] ? (P * length) : Q;
}
int min_cost = INT_MAX;
for (int mid = start; mid < end; ++mid) {
int left_length = mid - start + 1;
int right_length = end - mid;
int left_cost = minCost(start, mid, P, Q, is_special);
int right_cost = minCost(mid + 1, end, P, Q, is_special);
min_cost = min(min_cost, left_cost + right_cost);
}
min_cost = min(min_cost, is_special[start] ? (P * length) : Q);
return min_cost;
}
bool is_power_of_two(int n) {
return (n & (n - 1)) == 0;
}
};
BNYโ
#include <vector>
#include <algorithm>
#include <unordered_map>
#include<climits>
using namespace std;
const int MOD = 1e9 + 7;
class Solution {
public:
int removeIntegers(int N, int P, int Q, vector<int>& special_integers) {
sort(special_integers.begin(), special_integers.end());
unordered_map<int, bool> is_special;
for (int num : special_integers)
is_special[num] = true;
return minCost(1, 1 << N, P, Q, is_special);
}
private:
int minCost(int start, int end, int P, int Q, unordered_map<int, bool>& is_special) {
int length = end - start + 1;
if (length == 1) {
return is_special[start] ? P : Q;
}
if (is_power_of_two(length)) {
return is_special[start] ? (P * length) : Q;
}
int min_cost = INT_MAX;
for (int mid = start; mid < end; ++mid) {
int left_length = mid - start + 1;
int right_length = end - mid;
int left_cost = minCost(start, mid, P, Q, is_special);
int right_cost = minCost(mid + 1, end, P, Q, is_special);
min_cost = min(min_cost, left_cost + right_cost);
}
min_cost = min(min_cost, is_special[start] ? (P * length) : Q);
return min_cost;
}
bool is_power_of_two(int n) {
return (n & (n - 1)) == 0;
}
};
BNYโ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
import java.util.*;
public class Main {
static int countUniqueSubsets(int[] arr, int N, int K) {
Arrays.sort(arr);
return countUniqueSubsetsUtil(arr, N, K, 0, 0);
}
static int countUniqueSubsetsUtil(int[] arr, int N, int K, int currentIndex, int currentSum) {
if (currentSum == K) {
return 1;
}
if (currentSum > K || currentIndex >= N) {
return 0;
}
int count = 0;
count += countUniqueSubsetsUtil(arr, N, K, currentIndex + 1, currentSum + arr[currentIndex]);
while (currentIndex + 1 < N && arr[currentIndex] == arr[currentIndex + 1]) {
currentIndex++;
}
count += countUniqueSubsetsUtil(arr, N, K, currentIndex + 1, currentSum);
return count;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int K = scanner.nextInt();
int[] arr = new int[N];
for (int i = 0; i < N; i++) {
arr[i] = scanner.nextInt();
}
System.out.println(countUniqueSubsets(arr, N, K));
}
}
The puzzle masters of puzzleville โ
public class Main {
static int countUniqueSubsets(int[] arr, int N, int K) {
Arrays.sort(arr);
return countUniqueSubsetsUtil(arr, N, K, 0, 0);
}
static int countUniqueSubsetsUtil(int[] arr, int N, int K, int currentIndex, int currentSum) {
if (currentSum == K) {
return 1;
}
if (currentSum > K || currentIndex >= N) {
return 0;
}
int count = 0;
count += countUniqueSubsetsUtil(arr, N, K, currentIndex + 1, currentSum + arr[currentIndex]);
while (currentIndex + 1 < N && arr[currentIndex] == arr[currentIndex + 1]) {
currentIndex++;
}
count += countUniqueSubsetsUtil(arr, N, K, currentIndex + 1, currentSum);
return count;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int K = scanner.nextInt();
int[] arr = new int[N];
for (int i = 0; i < N; i++) {
arr[i] = scanner.nextInt();
}
System.out.println(countUniqueSubsets(arr, N, K));
}
}
The puzzle masters of puzzleville โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
import java.util.*;
import java.io.*;
class Main {
public static void main(String args[]) throws Exception {
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
int indent = 0;
boolean inQuotes = false;
StringBuilder output = new StringBuilder();
for (char ch : input.toCharArray()) {
switch (ch) {
case '{':
case '[':
output.append(ch);
if (!inQuotes) {
output.append("\n");
indent++;
appendIndentation(output, indent);
}
break;
case '}':
case ']':
if (!inQuotes) {
output.append("\n");
indent--;
appendIndentation(output, indent);
}
output.append(ch);
break;
case ',':
output.append(ch);
if (!inQuotes) {
output.append("\n");
appendIndentation(output, indent);
}
break;
case '"':
output.append(ch);
inQuotes = !inQuotes;
break;
default:
output.append(ch);
break;
}
}
System.out.println(output.toString());
}
private static void appendIndentation(StringBuilder sb, int indent) {
for (int i = 0; i < indent; i++) {
sb.append("**");
}
}
}
Json formatter โ
import java.io.*;
class Main {
public static void main(String args[]) throws Exception {
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
int indent = 0;
boolean inQuotes = false;
StringBuilder output = new StringBuilder();
for (char ch : input.toCharArray()) {
switch (ch) {
case '{':
case '[':
output.append(ch);
if (!inQuotes) {
output.append("\n");
indent++;
appendIndentation(output, indent);
}
break;
case '}':
case ']':
if (!inQuotes) {
output.append("\n");
indent--;
appendIndentation(output, indent);
}
output.append(ch);
break;
case ',':
output.append(ch);
if (!inQuotes) {
output.append("\n");
appendIndentation(output, indent);
}
break;
case '"':
output.append(ch);
inQuotes = !inQuotes;
break;
default:
output.append(ch);
break;
}
}
System.out.println(output.toString());
}
private static void appendIndentation(StringBuilder sb, int indent) {
for (int i = 0; i < indent; i++) {
sb.append("**");
}
}
}
Json formatter โ