#define ll long long
using namespace std;
ll solve(ll A, ll B) {
ll rounds = 0;
while (A != B) {
if (A > B) {
A = A - B;
} else {
B = B - A;
}
rounds++;
}
return rounds;
}
int main() {
ll A, B;
cin >> A >> B;
ll rounds = solve(A, B);
cout << rounds << endl;
return 0;
}
Flipkart โ
using namespace std;
ll solve(ll A, ll B) {
ll rounds = 0;
while (A != B) {
if (A > B) {
A = A - B;
} else {
B = B - A;
}
rounds++;
}
return rounds;
}
int main() {
ll A, B;
cin >> A >> B;
ll rounds = solve(A, B);
cout << rounds << endl;
return 0;
}
Flipkart โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
import heapq
def dijkstra_with_cycle(nodes, roads_from, roads_to, roads_weight, start):
n = len(nodes)
distances = [float('inf')] * n
prev_node = [-1] * n
visited = [False] * n
pq = [(0, start)]
while pq:
dist, node = heapq.heappop(pq)
if visited[node]:
continue
visited[node] = True
for i in range(len(roads_from)):
if roads_from[i] == node:
neighbor = roads_to[i]
weight = roads_weight[i]
if distances[node] + weight < distances[neighbor]:
distances[neighbor] = (distances[node] if node != start else 0) + weight
prev_node[neighbor] = node
heapq.heappush(pq, (distances[neighbor], neighbor))
elif neighbor == start and distances[node] + weight < distances[start]:
distances[start] = distances[node] + weight
prev_node[start] = node
return distances[start] if distances[start] != float('inf') else 0
Minimum Distance to reach home โ
def dijkstra_with_cycle(nodes, roads_from, roads_to, roads_weight, start):
n = len(nodes)
distances = [float('inf')] * n
prev_node = [-1] * n
visited = [False] * n
pq = [(0, start)]
while pq:
dist, node = heapq.heappop(pq)
if visited[node]:
continue
visited[node] = True
for i in range(len(roads_from)):
if roads_from[i] == node:
neighbor = roads_to[i]
weight = roads_weight[i]
if distances[node] + weight < distances[neighbor]:
distances[neighbor] = (distances[node] if node != start else 0) + weight
prev_node[neighbor] = node
heapq.heappush(pq, (distances[neighbor], neighbor))
elif neighbor == start and distances[node] + weight < distances[start]:
distances[start] = distances[node] + weight
prev_node[start] = node
return distances[start] if distances[start] != float('inf') else 0
Minimum Distance to reach home โ
#include<bits/stdc++.h>
using namespace std;
struct edge {
int u, v, w;
bool operator<(const edge& rhs) const {
return w > rhs.w;
}
};
vector<int> parent, rank_;
int find(int i) {
if (i != parent[i])
parent[i] = find(parent[i]);
return parent[i];
}
void union_set(int i, int j) {
int ri = find(i), rj = find(j);
if (ri != rj) {
if (rank_[ri] > rank_[rj])
swap(ri, rj);
parent[ri] = rj;
if (rank_[ri] == rank_[rj])
rank_[rj]++;
}
}
int main() {
int n, m;
cin >> n >> m;
vector<int> cost(n);
for (int i = 0; i < n; i++)
cin >> cost[i];
vector<edge> edges(m);
for (int i = 0; i < m; i++) {
cin >> edges[i].u >> edges[i].v >> edges[i].w;
edges[i].u--; edges[i].v--;
}
parent.resize(n);
rank_.resize(n);
for (int i = 0; i < n; i++)
parent[i] = i;
priority_queue<edge> pq;
for (int i = 0; i < n; i++)
for (int j = i+1; j < n; j++)
pq.push({i, j, cost[i] + cost[j]});
for (auto& e : edges)
pq.push(e);
int total_cost = 0;
while (!pq.empty()) {
edge e = pq.top();
pq.pop();
if (find(e.u) != find(e.v)) {
total_cost += e.w;
union_set(e.u, e.v);
}
}
cout << total_cost << endl;
return 0;
}
Connect the country 2โ
using namespace std;
struct edge {
int u, v, w;
bool operator<(const edge& rhs) const {
return w > rhs.w;
}
};
vector<int> parent, rank_;
int find(int i) {
if (i != parent[i])
parent[i] = find(parent[i]);
return parent[i];
}
void union_set(int i, int j) {
int ri = find(i), rj = find(j);
if (ri != rj) {
if (rank_[ri] > rank_[rj])
swap(ri, rj);
parent[ri] = rj;
if (rank_[ri] == rank_[rj])
rank_[rj]++;
}
}
int main() {
int n, m;
cin >> n >> m;
vector<int> cost(n);
for (int i = 0; i < n; i++)
cin >> cost[i];
vector<edge> edges(m);
for (int i = 0; i < m; i++) {
cin >> edges[i].u >> edges[i].v >> edges[i].w;
edges[i].u--; edges[i].v--;
}
parent.resize(n);
rank_.resize(n);
for (int i = 0; i < n; i++)
parent[i] = i;
priority_queue<edge> pq;
for (int i = 0; i < n; i++)
for (int j = i+1; j < n; j++)
pq.push({i, j, cost[i] + cost[j]});
for (auto& e : edges)
pq.push(e);
int total_cost = 0;
while (!pq.empty()) {
edge e = pq.top();
pq.pop();
if (find(e.u) != find(e.v)) {
total_cost += e.w;
union_set(e.u, e.v);
}
}
cout << total_cost << endl;
return 0;
}
Connect the country 2โ
๐2๐1
#include <vector>
#include <map>
#include <algorithm>
const long INF = LONG_MAX / 10;
long dfs(int i, const vector<int>& cost, int timeSoFar, const vector<int>& time, vector<map<int, long>>& memo) {
int n = cost.size();
if (i == n) return timeSoFar >= 0 ? 0 : INF;
if (timeSoFar >= n - i) return 0;
if (memo[i].count(timeSoFar)) return memo[i][timeSoFar];
long resPaid = cost[i] + dfs(i + 1, cost, timeSoFar + time[i], time, memo); // paid server
long resFree = dfs(i + 1, cost, timeSoFar - 1, time, memo); // free server
memo[i][timeSoFar] = min(resPaid, resFree);
return memo[i][timeSoFar];
}
long getMinCost(const vector<int>& cost, const vector<int>& time) {
vector<map<int, long>> memo(cost.size());
return dfs(0, cost, 0, time, memo);
}
Task Schedulingโ
#include <map>
#include <algorithm>
const long INF = LONG_MAX / 10;
long dfs(int i, const vector<int>& cost, int timeSoFar, const vector<int>& time, vector<map<int, long>>& memo) {
int n = cost.size();
if (i == n) return timeSoFar >= 0 ? 0 : INF;
if (timeSoFar >= n - i) return 0;
if (memo[i].count(timeSoFar)) return memo[i][timeSoFar];
long resPaid = cost[i] + dfs(i + 1, cost, timeSoFar + time[i], time, memo); // paid server
long resFree = dfs(i + 1, cost, timeSoFar - 1, time, memo); // free server
memo[i][timeSoFar] = min(resPaid, resFree);
return memo[i][timeSoFar];
}
long getMinCost(const vector<int>& cost, const vector<int>& time) {
vector<map<int, long>> memo(cost.size());
return dfs(0, cost, 0, time, memo);
}
Task Schedulingโ
def largestArea(samples):
R = len(samples)
C = len(samples[0])
S = [[0] * C for _ in range(R)]
M = [[0] * C for _ in range(R)]
for d in range(R):
for b in range(C):
M[d][b] = samples[d][b]
for i in range(R):
S[i][0] = M[i][0]
for j in range(C):
S[0][j] = M[0][j]
for i in range(1, R):
for j in range(1, C):
if M[i][j] == 1:
S[i][j] = min(S[i][j-1], min(S[i-1][j], S[i-1][j-1])) + 1
else:
S[i][j] = 0
max_of_s = S[0][0]
max_i = 0
max_j = 0
for i in range(R):
for j in range(C):
if max_of_s < S[i][j]:
max_of_s = S[i][j]
max_i = i
max_j = j
return abs(max_i - max_of_s) - max_i
Product Defects โ
R = len(samples)
C = len(samples[0])
S = [[0] * C for _ in range(R)]
M = [[0] * C for _ in range(R)]
for d in range(R):
for b in range(C):
M[d][b] = samples[d][b]
for i in range(R):
S[i][0] = M[i][0]
for j in range(C):
S[0][j] = M[0][j]
for i in range(1, R):
for j in range(1, C):
if M[i][j] == 1:
S[i][j] = min(S[i][j-1], min(S[i-1][j], S[i-1][j-1])) + 1
else:
S[i][j] = 0
max_of_s = S[0][0]
max_i = 0
max_j = 0
for i in range(R):
for j in range(C):
if max_of_s < S[i][j]:
max_of_s = S[i][j]
max_i = i
max_j = j
return abs(max_i - max_of_s) - max_i
Product Defects โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company โ DueToHQ
Role โ Business Analytics Internship
Exp. โ Fresher
Apply Here โ https://internshala.com/internship/details/work-from-home-business-analytics-internship-at-duetohq1713164431?utm_source=cp_link&referral=web_share
Company โ PapaSiddhi
Role โ Machine Learning Development
Exp. โ Fresher
Apply Here โ https://internshala.com/internship/details/machine-learning-development-internship-in-udaipur-at-papasiddhi1713153810?utm_source=cp_link&referral=web_share
Company โ Ozibook Tech Solutions Private Limited
Role โ Data Analytics Internship
Exp. โ Fresher
Apply Here โ https://internshala.com/internship/details/work-from-home-part-time-data-analytics-internship-at-ozibook-tech-solutions-private-limited1713066596?utm_source=cp_link&referral=web_share
Role โ Business Analytics Internship
Exp. โ Fresher
Apply Here โ https://internshala.com/internship/details/work-from-home-business-analytics-internship-at-duetohq1713164431?utm_source=cp_link&referral=web_share
Company โ PapaSiddhi
Role โ Machine Learning Development
Exp. โ Fresher
Apply Here โ https://internshala.com/internship/details/machine-learning-development-internship-in-udaipur-at-papasiddhi1713153810?utm_source=cp_link&referral=web_share
Company โ Ozibook Tech Solutions Private Limited
Role โ Data Analytics Internship
Exp. โ Fresher
Apply Here โ https://internshala.com/internship/details/work-from-home-part-time-data-analytics-internship-at-ozibook-tech-solutions-private-limited1713066596?utm_source=cp_link&referral=web_share
Internshala
Business Analytics Work From Home Internship at DueToHQ
Selected intern's day-to-day responsibilities include:
Assist in collecting, organizing, and analyzing data from various sources to identify trends, patterns, and opportunities.
Work closely with cross-functional teams to understand business requirementsโฆ
Assist in collecting, organizing, and analyzing data from various sources to identify trends, patterns, and opportunities.
Work closely with cross-functional teams to understand business requirementsโฆ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐interactly.video is hiring for the role of Frontend Intern (ReactJs)
Batch: 2024, 2025
Stipend: 25K-30K per month
๐Apply here: https://wellfound.com/l/2zfith
๐1010Analytics is hiring for the role of SDE Intern (Rust Developer)
Stipend: 25K-30K per month
๐Apply here: https://wellfound.com/l/2A97P5
๐Elchemy is hiring for the role of SDE Intern
Batch: 2024, 2025
Stipend: 15-20K
๐Apply here: https://wellfound.com/l/2A8ZUB
Batch: 2024, 2025
Stipend: 25K-30K per month
๐Apply here: https://wellfound.com/l/2zfith
๐1010Analytics is hiring for the role of SDE Intern (Rust Developer)
Stipend: 25K-30K per month
๐Apply here: https://wellfound.com/l/2A97P5
๐Elchemy is hiring for the role of SDE Intern
Batch: 2024, 2025
Stipend: 15-20K
๐Apply here: https://wellfound.com/l/2A8ZUB
Wellfound (formerly AngelList Talent)
ReactJs Front End Developer Intern at interactly.video โข Hyderabad
interactly.video is hiring a ReactJs Front End Developer Intern in Hyderabad - Apply now on Wellfound (formerly AngelList Talent)! **Job Description**
We are looking for a JavaScript developer who has...
We are looking for a JavaScript developer who has...
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Maruti Suzuki All India Hiring Test:
Role: Assistant Manager
Graduation Year: 2022
Degree: B.Tech / M.Tech
Eligible Branches: Mechanical, Automobile, Civil, Electrical, Electronics, Mechatronics and Tool & Die
Age: 21 to 27 years
Work Experience: 12 to 22 months
Selection Process:
1. Profile Shortlisting
2. Online Test (Technical, Aptitude & Psychometric)
3. Personal Interview (Technical + HR)
4. Offer
5. Medical Test
6. Joining
B.Tech CTC: 10.34 LPA (8.3 LPA - Fixed)
M.Tech CTC: 10.99 LPA (8.85 LPA Fixed)
Location: PAN - India
Apply Link: https://maruti.app.param.ai/jobs/all-india-hiring-ait-2024-btech-and-mtech
Last Date to Apply: 21st April 2024
Role: Assistant Manager
Graduation Year: 2022
Degree: B.Tech / M.Tech
Eligible Branches: Mechanical, Automobile, Civil, Electrical, Electronics, Mechatronics and Tool & Die
Age: 21 to 27 years
Work Experience: 12 to 22 months
Selection Process:
1. Profile Shortlisting
2. Online Test (Technical, Aptitude & Psychometric)
3. Personal Interview (Technical + HR)
4. Offer
5. Medical Test
6. Joining
B.Tech CTC: 10.34 LPA (8.3 LPA - Fixed)
M.Tech CTC: 10.99 LPA (8.85 LPA Fixed)
Location: PAN - India
Apply Link: https://maruti.app.param.ai/jobs/all-india-hiring-ait-2024-btech-and-mtech
Last Date to Apply: 21st April 2024
๐2
private static double[] calculateMovingAverage(int[] array, int K) {
double[] smoothedArray = new double[array.length - K + 1];
double sum = 0;
for (int i = 0; i < K; i++) {
sum += array[i];
}
for (int i = 0; i <= array.length - K; i++) {
if (i > 0) {
sum = sum - array[i - 1] + array[i + K - 1];
}
smoothedArray[i] = sum / K;
}
return smoothedArray;
}
Moving Averagesโ
double[] smoothedArray = new double[array.length - K + 1];
double sum = 0;
for (int i = 0; i < K; i++) {
sum += array[i];
}
for (int i = 0; i <= array.length - K; i++) {
if (i > 0) {
sum = sum - array[i - 1] + array[i + K - 1];
}
smoothedArray[i] = sum / K;
}
return smoothedArray;
}
Moving Averagesโ
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Global Payments
๐ Job Title: Associate Software Engineer
โ๐ป YOE: 0-1 years
โก๏ธ Apply: https://jobs.globalpayments.com/en/jobs/r0048707/associate-software-engineer/
Please do share in your college grps and in case you are applying please react on this post:) ๐โค๏ธ
๐ Job Title: Associate Software Engineer
โ๐ป YOE: 0-1 years
โก๏ธ Apply: https://jobs.globalpayments.com/en/jobs/r0048707/associate-software-engineer/
Please do share in your college grps and in case you are applying please react on this post:) ๐โค๏ธ
โค1
#include <iostream>
#include <vector>
using namespace std;
int divideTerritory(int n, vector<int>& qualities) {
int totalQuality = 0;
for (int i = 0; i < n; ++i) {
totalQuality += qualities[i];
}
if (totalQuality % 3 != 0) {
return 0;
}
int targetQuality = totalQuality / 3;
vector<int> prefixSums(n, 0);
int currentSum = 0;
int count = 0;
for (int i = 0; i < n; ++i) {
currentSum += qualities[i];
prefixSums[i] = currentSum;
}
for (int i = 0; i < n - 2; ++i) {
if (prefixSums[i] == targetQuality) {
for (int j = i + 1; j < n - 1; ++j) {
if (prefixSums[j] - prefixSums[i] == targetQuality && prefixSums.back() - prefixSums[j] == targetQuality) {
count++;
}
}
}
}
return count;
}
Three little pigs โ
#include <vector>
using namespace std;
int divideTerritory(int n, vector<int>& qualities) {
int totalQuality = 0;
for (int i = 0; i < n; ++i) {
totalQuality += qualities[i];
}
if (totalQuality % 3 != 0) {
return 0;
}
int targetQuality = totalQuality / 3;
vector<int> prefixSums(n, 0);
int currentSum = 0;
int count = 0;
for (int i = 0; i < n; ++i) {
currentSum += qualities[i];
prefixSums[i] = currentSum;
}
for (int i = 0; i < n - 2; ++i) {
if (prefixSums[i] == targetQuality) {
for (int j = i + 1; j < n - 1; ++j) {
if (prefixSums[j] - prefixSums[i] == targetQuality && prefixSums.back() - prefixSums[j] == targetQuality) {
count++;
}
}
}
}
return count;
}
Three little pigs โ
#include <iostream>
#include <string>
#include <stack>
using namespace std;
int solve(const string& s) {
stack<char> stk;
int insertions = 0;
for (char c : s) {
if (c == '(') {
stk.push(c);
} else {
if (stk.empty()) {
insertions++;
} else {
stk.pop();
}
}
}
insertions += stk.size();
return insertions;
}
The String โ
#include <string>
#include <stack>
using namespace std;
int solve(const string& s) {
stack<char> stk;
int insertions = 0;
for (char c : s) {
if (c == '(') {
stk.push(c);
} else {
if (stk.empty()) {
insertions++;
} else {
stk.pop();
}
}
}
insertions += stk.size();
return insertions;
}
The String โ