#include <bits/stdc++.h>
using namespace std;
vector<int> getGreatestElements(vector<int>& arr, int k) {
int n = arr.size();
vector<int> result;
priority_queue<int, vector<int>, greater<int>> minHeap;
for (int i = 0; i < n; ++i) {
minHeap.push(arr[i]);
if (minHeap.size() > k) {
minHeap.pop();
}
if (i >= k - 1) {
result.push_back(minHeap.top());
}
}
return result;
}
Gamekraft โ
from collections import defaultdict
def getMaxRacers(speed, k):
ans = 0
D = defaultdict(list)
for i, e in enumerate(speed):
D[e].append(i)
for arr in D.values():
l = 0
for r in range(len(arr)):
while r > l and arr[r] - arr[l] - (r - l) > k:
l += 1
ans = max(ans, r - l + 1)
return ans
GAMESKRAFT MAXRACERS โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
long long answer(vector<int>& arr, int i, vector<long long>& dp) {
if (i >= arr.size()) {
return 0;
}
if (dp[i] != -1) {
return dp[i];
}
long long include = arr[i] | answer(arr, i + 1, dp);
long long exclude = answer(arr, i + 1, dp);
return dp[i] = max(include, exclude);
}
long long solve(int N, vector<int>& arr) {
vector<long long> dp(N, -1);
return answer(arr, 0, dp);
}
OR Bit โ
Siemens
#include <iostream>
#include <vector>
using namespace std;
int solve(int N, vector<int> workload) {
int tot = 0;
int maxTot = 0;
for (auto i : workload) {
if (i > 6) {
tot++;
} else {
tot = 0;
}
if (tot > maxTot) {
maxTot = tot;
}
}
return maxTot;
}
Peak output โ
Siemens
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
#include <iostream> #include <vector> using namespace std; int solve(int N, vector<int> workload) { int tot = 0; int maxTot = 0; for (auto i : workload) { if (i > 6) { tot++; } else { tot = 0; } โฆ
def solve(N, workload):
msd = 0
cs = 0
for hours in workload:
if hours > 6:
cs += 1
msd = max(msd, cs)
else:
current_streak = 0
return msd
Peak output โ
Siemens
def solve(N, Q, Specs, Queries):
aa = {}
for price, ram, storage in Specs:
if (ram, storage) in aa:
aa[(ram, storage)] = min(aa[(ram, storage)], price)
else:
aa[(ram, storage)] = price
results = []
for ram_req, storage_req in Queries:
if (ram_req, storage_req) in aa:
results.append(aa[(ram_req, storage_req)])
else:
results.append(-1)
return results
Who wins the game
Google โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Barclays
Role: Software Engineer
Batch eligible: 2022, 2023 and 2024 grads
Apply: https://search.jobs.barclays/job/-/-/13015/68431136944
Role: Software Engineer
Batch eligible: 2022, 2023 and 2024 grads
Apply: https://search.jobs.barclays/job/-/-/13015/68431136944
search.jobs.barclays
Software Engineer at Barclays
Learn more about applying for Software Engineer at Barclays
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Deloitte
Role: Software Engineering Summer Scholar
Batch eligible: 2026 grads only
Apply: https://apply.deloitte.com/careers/JobDetail/Deloitte-Consulting-Software-Engineering-Summer-Scholar/185362
Role: Software Engineering Summer Scholar
Batch eligible: 2026 grads only
Apply: https://apply.deloitte.com/careers/JobDetail/Deloitte-Consulting-Software-Engineering-Summer-Scholar/185362
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Trellix
Role: Software Engineer Intern
Batch eligible: 2025 and 2026 grads
Apply: https://trellix.wd1.myworkdayjobs.com/EnterpriseCareers/job/India-Bangalore/Software-Engineer-Intern_JR0034042
Role: Software Engineer Intern
Batch eligible: 2025 and 2026 grads
Apply: https://trellix.wd1.myworkdayjobs.com/EnterpriseCareers/job/India-Bangalore/Software-Engineer-Intern_JR0034042
#include <bits/stdc++.h>
using namespace std;
pair<int, int> countVC(const string& w) {
unordered_set<char> v{'a', 'e', 'i', 'o', 'u'};
int vc = 0;
int cc = 0;
for (char c : w) {
if (v.find(c) != v.end()) {
vc++;
} else {
cc++;
}
}
return {vc, cc};
}
bool cmp(const pair<string, int>& a, const pair<string, int>& b) {
if (a.second == b.second) {
return a.first < b.first;
}
return a.second < b.second;
}
vector<string> sortWords(const string& t) {
vector<string> ws;
stringstream ss(t);
string w;
while (ss >> w) {
ws.push_back(w);
}
vector<pair<string, int>> wd;
for (const string& w : ws) {
auto [vc, cc] = countVC(w);
int diff = abs(vc - cc);
wd.emplace_back(w, diff);
}
sort(wd.begin(), wd.end(), cmp);
vector<string> res;
for (const auto& p : wd) {
res.push_back(p.first);
}
return res;
}
yugaByte โ
from math import gcd
from functools import reduce
def solve(n, arr):
array_gcd = reduce(gcd, arr)
return sum(arr) // array_gcd
Winzo Building Blocksโ
def minimum_payment(N, numbers):
sorted_nums = sorted(numbers)
median = sorted_nums[N // 2]
total_cost = sum(abs(num - median) for num in numbers)
return total_cost
Winzo Equal Numbersโ
#include <bits/stdc++.h>
using namespace std;
bool isPrime(int num) {
if (num <= 1) return false;
if (num == 2 || num == 3) return true;
if (num % 2 == 0 || num % 3 == 0) return false;
for (int i = 5; i * i <= num; i += 6) {
if (num % i == 0 || num % (i + 2) == 0) return false;
}
return true;
}
int calculateGrundy(int x, int y) {
return x ^ y;
}
char solve(int N, vector<pair<int, int>>& stones) {
int xorGrundy = 0;
for (const auto& stone : stones) {
int x = stone.first;
int y = stone.second;
xorGrundy ^= calculateGrundy(x, y);
}
return (xorGrundy == 0) ? 'B' : 'A';
}
int main() {
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
vector<pair<int, int>> stones(N);
for (int i = 0; i < N; i++) {
int x, y;
cin >> x >> y;
stones[i] = {x, y};
}
cout << solve(N, stones) << endl;
}
return 0;
}
game of stones
Siemensโ
def findMinComplexity(complexity, days):
n = len(complexity)
if days > n:
return -1
dp = [[float('inf')] * (days + 1) for _ in range(n + 1)]
dp[0][0] = 0
for i in range(1, n + 1):
for j in range(1, min(i, days) + 1):
max_complexity = 0
for k in range(i, j - 1, -1):
max_complexity = max(max_complexity, complexity[k - 1])
dp[i][j] = min(dp[i][j], dp[k - 1][j - 1] + max_complexity)
return dp[n][days]
Minimum complexity level
Mathwork โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
def findMinComplexity(complexity, days): n = len(complexity) if days > n: return -1 dp = [[float('inf')] * (days + 1) for _ in range(n + 1)] dp[0][0] = 0 for i in range(1, n + 1): for j in range(1, min(i, days)โฆ
#include <iostream>
#include <vector>
using namespace std;
vector<int> solution(const vector<int>& numbers) {
vector<int> result;
int start = 0;
int end = numbers.size() - 1;
while (start <= end) {
if (start <= end) {
result.push_back(numbers[start]);
++start;
}
if (start <= end) {
result.push_back(numbers[end]);
--end;
}
}
return result;
}
Tradedesk โ
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
void bfs(const vector<vector<int>>& adj, vector<bool>& visited, int start) {
queue<int> q;
q.push(start);
visited[start] = true;
while (!q.empty()) {
int u = q.front();
q.pop();
for (int v : adj[u]) {
if (!visited[v]) {
visited[v] = true;
q.push(v);
}
}
}
}
bool isConnected(const vector<vector<int>>& adj, int N, int C) {
vector<bool> visited(N, false);
bfs(adj, visited, C);
for (bool v : visited) {
if (!v) return false;
}
return true;
}
int countComponents(const vector<vector<int>>& adj, int N) {
vector<bool> visited(N, false);
int components = 0;
for (int i = 0; i < N; ++i) {
if (!visited[i]) {
bfs(adj, visited, i);
++components;
}
}
return components;
}
int main() {
int T;
cin >> T;
while (T--) {
int N, M;
cin >> N >> M;
vector<vector<int>> adj(N);
for (int i = 0; i < M; ++i) {
int A, B;
cin >> A >> B;
adj[A].push_back(B);
adj[B].push_back(A);
}
int C;
cin >> C;
if (isConnected(adj, N, C)) {
cout << "Yes" << endl;
} else {
int components = countComponents(adj, N);
cout << "No" << endl;
cout << components - 1 << endl;
}
}
return 0;
}
bob and the tour โ