Distance between two points โ
Zscaler
Zscaler
SELECT ID, NAME
FROM CUSTOMER
ORDER BY NAME DESC, ID ASC;
Order management system โ
Zscaler
FROM CUSTOMER
ORDER BY NAME DESC, ID ASC;
Order management system โ
Zscaler
vector<string> processLogs(vector<string> logs, int threshold)
}
Suspicious activity from logs โ
{
unordered_map<string, int> transaction_cou
nt;
for (const string& log : logs
) {
istringstream iss(lo
g);
string sender, recipie
nt;
int amou
nt;
iss >> sender >> recipient >> amou
nt;
transaction_count[sender]
++;
if (sender != recipient
) {
transaction_count[recipient]
++;
}
}
vector<string> suspicious_use
rs;
for (const auto& entry : transaction_count
) {
if (entry.second >= threshold
) {
suspicious_users.push_back(entry.firs
t);
}
}
sort(suspicious_users.begin(), suspicious_users.end(
));
return suspicious_use
rs
;}
Suspicious activity from logs โ
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int findMinWeight(vector<int> weights, int d) {
priority_queue<int> maxHeap(weights.begin(), weights.end());
for (int i = 0; i < d; ++i) {
int maxWeight = maxHeap.top();
maxHeap.pop();
int remainingWeight = maxWeight / 2;
maxHeap.push(maxWeight - remainingWeight);
}
int totalWeight = 0;
while (!maxHeap.empty()) {
totalWeight += maxHeap.top();
maxHeap.pop();
}
return totalWeight;
}
Minimum total weight โ
#include <vector>
#include <queue>
using namespace std;
int findMinWeight(vector<int> weights, int d) {
priority_queue<int> maxHeap(weights.begin(), weights.end());
for (int i = 0; i < d; ++i) {
int maxWeight = maxHeap.top();
maxHeap.pop();
int remainingWeight = maxWeight / 2;
maxHeap.push(maxWeight - remainingWeight);
}
int totalWeight = 0;
while (!maxHeap.empty()) {
totalWeight += maxHeap.top();
maxHeap.pop();
}
return totalWeight;
}
Minimum total weight โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Solution {
public:
int maximumInvitations(vector<int>& favourite) {
int n = favourite.size();
vector<bool> duoNode(n, false);
vector<int> indegree(n, 0);
vector<int> maxPathAt(n, 1);
for (int i = 0; i < n; i++) {
indegree[favourite[i]]++;
if (favourite[favourite[i]] == i) {
duoNode[i] = true;
duoNode[favourite[i]] = true;
}
}
int ans = 0;
vector<bool> visited(n, false);
for (int i = 0; i < n; i++) {
if (!indegree[i]) {
int cur = i;
while (!duoNode[cur] && !visited[cur] && !indegree[cur]) {
visited[cur] = true;
maxPathAt[favourite[cur]] = max(maxPathAt[favourite[cur]], maxPathAt[cur] + 1);
cur = favourite[cur];
indegree[cur]--;
}
}
}
for (int i = 0; i < n; i++) {
if (duoNode[i]) {
ans += maxPathAt[i];
}
}
int offset = 1;
fill(maxPathAt.begin(), maxPathAt.end(), 0);
fill(visited.begin(), visited.end(), false);
for (int i = 0; i < n; i++) {
if (!visited[i]) {
int prev, cur = i;
while (!maxPathAt[cur]) {
maxPathAt[cur] = offset++;
prev = cur;
cur = favourite[cur];
}
if (!visited[cur]) {
ans = max(ans, maxPathAt[prev] - maxPathAt[cur] + 1);
}
cur = i;
while (!visited[cur]) {
visited[cur] = true;
cur = favourite[cur];
}
}
}
return ans;
}
};
int main() {
Solution solution;
int N;
cin >> N;
vector<int> favourite(N);
for (int i = 0; i < N; i++) {
cin >> favourite[i];
favourite[i]--;
}
int result = solution.maximumInvitations(favourite);
cout << result << endl;
return 0;
}
Barclays โ
#include <vector>
#include <algorithm>
using namespace std;
class Solution {
public:
int maximumInvitations(vector<int>& favourite) {
int n = favourite.size();
vector<bool> duoNode(n, false);
vector<int> indegree(n, 0);
vector<int> maxPathAt(n, 1);
for (int i = 0; i < n; i++) {
indegree[favourite[i]]++;
if (favourite[favourite[i]] == i) {
duoNode[i] = true;
duoNode[favourite[i]] = true;
}
}
int ans = 0;
vector<bool> visited(n, false);
for (int i = 0; i < n; i++) {
if (!indegree[i]) {
int cur = i;
while (!duoNode[cur] && !visited[cur] && !indegree[cur]) {
visited[cur] = true;
maxPathAt[favourite[cur]] = max(maxPathAt[favourite[cur]], maxPathAt[cur] + 1);
cur = favourite[cur];
indegree[cur]--;
}
}
}
for (int i = 0; i < n; i++) {
if (duoNode[i]) {
ans += maxPathAt[i];
}
}
int offset = 1;
fill(maxPathAt.begin(), maxPathAt.end(), 0);
fill(visited.begin(), visited.end(), false);
for (int i = 0; i < n; i++) {
if (!visited[i]) {
int prev, cur = i;
while (!maxPathAt[cur]) {
maxPathAt[cur] = offset++;
prev = cur;
cur = favourite[cur];
}
if (!visited[cur]) {
ans = max(ans, maxPathAt[prev] - maxPathAt[cur] + 1);
}
cur = i;
while (!visited[cur]) {
visited[cur] = true;
cur = favourite[cur];
}
}
}
return ans;
}
};
int main() {
Solution solution;
int N;
cin >> N;
vector<int> favourite(N);
for (int i = 0; i < N; i++) {
cin >> favourite[i];
favourite[i]--;
}
int result = solution.maximumInvitations(favourite);
cout << result << endl;
return 0;
}
Barclays โ
#include <iostream>
using namespace std;
void cellCompete( int *arr, int days )
{
int num = 0;
for( int i = 0; i < 8; i++ )
{
num = ( num << 1 ) | arr[i];
}
for( int i = 0; i < days; i++ )
{
num = num << 1;
num = ( ( ( num << 1 ) ^ ( num >> 1 ) ) >> 1 ) & 0xFF;
}
for( int i = 0; i < 8; i++ )
{
arr[i] = ( num >> 7 - i ) & 0x01;
}
}
Pespico โ
using namespace std;
void cellCompete( int *arr, int days )
{
int num = 0;
for( int i = 0; i < 8; i++ )
{
num = ( num << 1 ) | arr[i];
}
for( int i = 0; i < days; i++ )
{
num = num << 1;
num = ( ( ( num << 1 ) ^ ( num >> 1 ) ) >> 1 ) & 0xFF;
}
for( int i = 0; i < 8; i++ )
{
arr[i] = ( num >> 7 - i ) & 0x01;
}
}
Pespico โ
import heapq
def minStops(a, b, c, d, e):
f = sorted(zip(b, c))
g = []
heapq.heapify(g)
h = e
i = 0
j = 0
for k in range(a):
l, m = f[k]
n = l - j
while h < n:
if not g:
return -1
h += -heapq.heappop(g)
i += 1
h -= n
j = l
heapq.heappush(g, -m)
o = d - j
while h < o:
if not g:
return -1
h += -heapq.heappop(g)
i += 1
return i
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Paypal
2023/22/21 passouts
Role : Associate Software Engineer
https://paypal.eightfold.ai/careers/job?domain=paypal.com&pid=274903982861&query=R0118464&domain=paypal.com&sort_by=relevance&job_index=0
2023/22/21 passouts
Role : Associate Software Engineer
https://paypal.eightfold.ai/careers/job?domain=paypal.com&pid=274903982861&query=R0118464&domain=paypal.com&sort_by=relevance&job_index=0
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company - Hugging Face
Role - ML Intern
Batch - 2023/2024/2025/2026
Stipend - 60-80k/month
Location - Remote
PPO after internship
Apply Link -
https://apply.workable.com/huggingface/j/0643507FC5/
Role - ML Intern
Batch - 2023/2024/2025/2026
Stipend - 60-80k/month
Location - Remote
PPO after internship
Apply Link -
https://apply.workable.com/huggingface/j/0643507FC5/
Workable
Hugging Face
Here at Hugging Face, weโre on a journey to advance and democratize ML for everyone. Along the way, we contribute to the development of technology for the better.
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <bits/stdc++.h>
using namespace std;
struct T {
string n;
int p, e;
T(string n, int p, int e) : n(n), p(p), e(e) {}
};
struct C {
bool operator()(const T &a, const T &b) {
if (a.p == b.p) return false;
return a.p < b.p;
}
};
vector<string> CircularPriorityDequeue(vector<string> a, vector<int> b, vector<int> c, vector<int> d) {
map<int, deque<T>, greater<int>> m;
vector<string> r;
for (int i = 0; i < a.size(); ++i) m[b[i]].emplace_back(a[i], b[i], c[i]);
for (int q : d) {
if (q == 1) {
if (m.empty()) {
r.push_back("Dequeued: EMPTY");
continue;
}
auto &h = m.begin()->second;
r.push_back("Dequeued: " + h.front().n);
h.pop_front();
if (h.empty()) m.erase(m.begin()->first);
} else if (q == 2) {
if (m.empty()) {
r.push_back("Executed: EMPTY");
continue;
}
auto &h = m.begin()->second;
r.push_back("Executed: " + h.front().n);
h.pop_front();
if (h.empty()) m.erase(m.begin()->first);
} else if (q == 3) {
int s = 0;
for (const auto &e : m) s += e.second.size();
r.push_back("Size: " + to_string(s));
}
}
return r;
}
Task Scheduling Optimization โ
Cars24
vector<vector<int>> adj;
vector<int> vis;
void solve() {
int n;
cin >> n;
adj.resize(n);
for(int i = 0 ; i < n ; i++){
int x;cin >> x;
int N = i + x;
int P = i - x;
if(N < n)
adj[N].push_back(i);
if(P >= 0)
adj[P].push_back(i);
}
vis.resize(n, -1);
queue<int> Q;
Q.push(n-1);
vis[n-1] = 0;
while(!Q.empty()){
int u = Q.front();
Q.pop();
for(int v : adj[u]){
if(vis[v] == -1){
Q.push(v);
vis[v] = 1 + vis[u];
}
}
}
for(int i = 0; i < n ; i++)
cout << vis[i] <<endl;
}
Servers Time โ
Razorpay
long long solve(int N,int M,vector<int>Arr){
vector<int>v(N+1,INT_MAX);
int n=N;
for(int i=n-1;i>=0;i--){
v[i]=min(v[i+1],Arr[i]);
}
long long ans=INT_MAX;
for(int i=0;i<N;i++){
if((i+M-1)<N){
ans=min(ans,1ll*Arr[i]*v[i+M-1]);
}
}
return ans;
}
Array transferโ
vector<int>v(N+1,INT_MAX);
int n=N;
for(int i=n-1;i>=0;i--){
v[i]=min(v[i+1],Arr[i]);
}
long long ans=INT_MAX;
for(int i=0;i<N;i++){
if((i+M-1)<N){
ans=min(ans,1ll*Arr[i]*v[i+M-1]);
}
}
return ans;
}
Array transferโ
class Solution{
public:
bool solvable(vector<int>& v,int diff,int K){
int n=v.size();
int prev=0;
int removed=0;
for(int i=1;i<n&&removed<K;i++){
if(i==n-1 || v[i+1]-v[prev]>diff){
if(v[i]-v[prev]>diff)return false;
prev=i;
}
else removed++;
}
return (removed==K);
}
int minDiff(vector<int> v,int K){
int hi=v.back()-v[0];
int lo=0;
for(int i=0;i+1<v.size();i++)lo=max(lo,v[i+1]-v[i]);
while(lo<hi){
int mid=(lo+hi)/2;
if(solvable(v,mid,K))hi=mid;
else lo=mid+1;
}
return lo;
}
};
Adjacent cubes โ
public:
bool solvable(vector<int>& v,int diff,int K){
int n=v.size();
int prev=0;
int removed=0;
for(int i=1;i<n&&removed<K;i++){
if(i==n-1 || v[i+1]-v[prev]>diff){
if(v[i]-v[prev]>diff)return false;
prev=i;
}
else removed++;
}
return (removed==K);
}
int minDiff(vector<int> v,int K){
int hi=v.back()-v[0];
int lo=0;
for(int i=0;i+1<v.size();i++)lo=max(lo,v[i+1]-v[i]);
while(lo<hi){
int mid=(lo+hi)/2;
if(solvable(v,mid,K))hi=mid;
else lo=mid+1;
}
return lo;
}
};
Adjacent cubes โ
MOD = 1000000007
def a(x):
if x <= 1:
return False
for i in range(2, int(x**0.5) + 1):
if x % i == 0:
return False
return True
def b(x):
c = []
for i in range(1, x+1):
if a(i):
c.append(i)
return c
def c(d, e, f):
g = [2, 3, 5, 7]
h = [0, 1, 4, 6, 8, 9]
i = b(d)
j = [[0] * e for _ in range(d+1)]
j[0][0] = 1
for k in range(1, d+1):
if k in i:
l = g
else:
l = h
for m in range(e):
for n in l:
if k == 1 and n == 0:
continue
o = (m * 10 + n) % e
j[k][o] = (j[k][o] + j[k-1][m]) % MOD
return j[d][f
[f] special Numbersโ