#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
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
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Linkedin
S.K. Varshney on LinkedIn: The Rhodes Trust Scholarship
A unique opportunity to study Masterโฆ
A unique opportunity to study Masterโฆ
The Rhodes Trust Scholarship
A unique opportunity to study Master courses at University of Oxford for those with strong academic records, leadershipโฆ
A unique opportunity to study Master courses at University of Oxford for those with strong academic records, leadershipโฆ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
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