Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Linkedin
Sign Up | LinkedIn
500 million+ members | Manage your professional identity. Build and engage with your professional network. Access knowledge, insights and opportunities.
#include <iostream>
#include <vector>
using namespace std;
int countBalancedSubarrays(const vector<int>& arr, int x) {
int n = arr.size();
vector<int> prefixSum(n + 1, 0);
int count = 0;
for (int i = 0; i < n; ++i) {
prefixSum[i + 1] = prefixSum[i] + arr[i];
}
for (int i = 0; i < x; ++i) {
for (int j = i; j < x; ++j) {
int subarraySum = prefixSum[j + 1] - prefixSum[i];
int subarrayLength = j - i + 1;
if (subarraySum == subarrayLength) {
count++;
}
}
}
return count;
}
int main() {
int t;
cin >> t;
for (int i = 0; i < t; ++i) {
int n, q;
cin >> n >> q;
vector<int> arr(n);
for (int j = 0; j < n; ++j) {
cin >> arr[j];
}
for (int j = 0; j < q; ++j) {
int x;
cin >> x;
int result = countBalancedSubarrays(arr, x);
cout << result << endl;
}
}
return 0;
}
ICPC Balance Subarray โ
#include <vector>
using namespace std;
int countBalancedSubarrays(const vector<int>& arr, int x) {
int n = arr.size();
vector<int> prefixSum(n + 1, 0);
int count = 0;
for (int i = 0; i < n; ++i) {
prefixSum[i + 1] = prefixSum[i] + arr[i];
}
for (int i = 0; i < x; ++i) {
for (int j = i; j < x; ++j) {
int subarraySum = prefixSum[j + 1] - prefixSum[i];
int subarrayLength = j - i + 1;
if (subarraySum == subarrayLength) {
count++;
}
}
}
return count;
}
int main() {
int t;
cin >> t;
for (int i = 0; i < t; ++i) {
int n, q;
cin >> n >> q;
vector<int> arr(n);
for (int j = 0; j < n; ++j) {
cin >> arr[j];
}
for (int j = 0; j < q; ++j) {
int x;
cin >> x;
int result = countBalancedSubarrays(arr, x);
cout << result << endl;
}
}
return 0;
}
ICPC Balance Subarray โ
from collections import deque
def bfs(graph, source, dest):
queue = deque([(source, 0)])
while queue:
node, dist = queue.popleft()
if node == dest:
return dist
for neighbor in graph[node]:
if neighbor != node:
queue.append((neighbor, dist + 1))
return -1
def solve():
t = int(input())
for _ in range(t):
n = int(input())
a, b, c = map(int, input().split())
graph = {}
for _ in range(n - 1):
x, y = map(int, input().split())
if x not in graph:
graph[x] = []
if y not in graph:
graph[y] = []
graph[x].append(y)
graph[y].append(x)
atoc = bfs(graph, a, c)
btoc = bfs(graph, b, c)
atob = bfs(graph, a, b)
if atoc < btoc:
print("A")
elif atob < atoc:
print("B")
elif btoc < atoc:
print("C")
else:
print("DRAW")
if name == "main":
solve()
Three Person โ ICPC
def bfs(graph, source, dest):
queue = deque([(source, 0)])
while queue:
node, dist = queue.popleft()
if node == dest:
return dist
for neighbor in graph[node]:
if neighbor != node:
queue.append((neighbor, dist + 1))
return -1
def solve():
t = int(input())
for _ in range(t):
n = int(input())
a, b, c = map(int, input().split())
graph = {}
for _ in range(n - 1):
x, y = map(int, input().split())
if x not in graph:
graph[x] = []
if y not in graph:
graph[y] = []
graph[x].append(y)
graph[y].append(x)
atoc = bfs(graph, a, c)
btoc = bfs(graph, b, c)
atob = bfs(graph, a, b)
if atoc < btoc:
print("A")
elif atob < atoc:
print("B")
elif btoc < atoc:
print("C")
else:
print("DRAW")
if name == "main":
solve()
Three Person โ ICPC
#include<bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> cust;
for(int i = 0; i < n; i++) {
int q, p;
cin >> q >> p;
cust.push_back({p, q});
}
vector<vector<int>> rice;
for(int i = 0; i < m; i++) {
int q, p;
cin >> q >> p;
rice.push_back({p, q});
}
sort(cust.begin(), cust.end());
sort(rice.begin(), rice.end());
vector<int> x(m, 0);
int ans = 0;
for(int i = 0; i < n; i++) {
int quantity = -1;
int index = -1;
for(int j = 0; j < m; j++) {
if (!x[j]) {
if (rice[j][0] > cust[i][0]) break;
if (rice[j][1] > cust[i][1]) {
if (quantity == -1) {
quantity = rice[j][1];
index = j;
} else {
if (quantity > rice[j][1]) {
index = j;
quantity = rice[j][1];
}
}
}
}
}
if (index != -1) {
x[index] = 1;
ans++;
}
}
cout << ans;
}
Super market Codevita โ
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> cust;
for(int i = 0; i < n; i++) {
int q, p;
cin >> q >> p;
cust.push_back({p, q});
}
vector<vector<int>> rice;
for(int i = 0; i < m; i++) {
int q, p;
cin >> q >> p;
rice.push_back({p, q});
}
sort(cust.begin(), cust.end());
sort(rice.begin(), rice.end());
vector<int> x(m, 0);
int ans = 0;
for(int i = 0; i < n; i++) {
int quantity = -1;
int index = -1;
for(int j = 0; j < m; j++) {
if (!x[j]) {
if (rice[j][0] > cust[i][0]) break;
if (rice[j][1] > cust[i][1]) {
if (quantity == -1) {
quantity = rice[j][1];
index = j;
} else {
if (quantity > rice[j][1]) {
index = j;
quantity = rice[j][1];
}
}
}
}
}
if (index != -1) {
x[index] = 1;
ans++;
}
}
cout << ans;
}
Super market Codevita โ
#include <stdio.h>
int cd=0,ca=0;
void bd(int array[], int n) {
for (int step = 0; step < n - 1; ++step) {
for (int i = 0; i < n - step - 1; ++i) {
if (array[i] < array[i + 1]) {
int temp = array[i];
array[i] = array[i + 1];
array[i + 1] = temp;
cd++;
}
}
}
}
void ba(int array[], int n) {
for (int step = 0; step < n - 1; ++step) {
for (int i = 0; i < n - step - 1; ++i) {
if (array[i] > array[i + 1]) {
int temp = array[i];
array[i] = array[i + 1];
array[i + 1] = temp;
ca++;
}
}
}
}
int main() {
int n;
scanf("%d",&n);
int da[n],dd[n];
for(int i=0;i<n;i++){
scanf("%d",&da[i]);
dd[i]=da[i];
}
ba(dd, n);
bd(da, n);
if(cd>ca)
printf("%d",ca);
else
printf("%d",cd);
}
Best Bubble Codevita โ
int cd=0,ca=0;
void bd(int array[], int n) {
for (int step = 0; step < n - 1; ++step) {
for (int i = 0; i < n - step - 1; ++i) {
if (array[i] < array[i + 1]) {
int temp = array[i];
array[i] = array[i + 1];
array[i + 1] = temp;
cd++;
}
}
}
}
void ba(int array[], int n) {
for (int step = 0; step < n - 1; ++step) {
for (int i = 0; i < n - step - 1; ++i) {
if (array[i] > array[i + 1]) {
int temp = array[i];
array[i] = array[i + 1];
array[i + 1] = temp;
ca++;
}
}
}
}
int main() {
int n;
scanf("%d",&n);
int da[n],dd[n];
for(int i=0;i<n;i++){
scanf("%d",&da[i]);
dd[i]=da[i];
}
ba(dd, n);
bd(da, n);
if(cd>ca)
printf("%d",ca);
else
printf("%d",cd);
}
Best Bubble Codevita โ
๐2
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
BNY Mellon Code Divas Diversity Challenge
Role: Software Developer
Batch eligible: 2024, 2025 and 2026 passouts
Apply: https://assessment.hackerearth.com/challenges/new/hiring/bny-mellon-women-challenge-2023/
Role: Software Developer
Batch eligible: 2024, 2025 and 2026 passouts
Apply: https://assessment.hackerearth.com/challenges/new/hiring/bny-mellon-women-challenge-2023/
HackerEarth
BNY Mellon Code Divas Diversity Challenge
Update - The test has been concluded early after a great participation volumn by candidates. An official email has been sent to you by HackerEarth informing the same.
BNY Mellon invites you to participate in the transformative challenge - Code Divas. Ourโฆ
BNY Mellon invites you to participate in the transformative challenge - Code Divas. Ourโฆ
๐1
Python 3โ
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Data Analytics Internship
Link!
https://msd.wd5.myworkdayjobs.com/en-US/SearchJobs/job/Data---Analytics-Intern---Data-Solutions_R269314-1
Link!
https://msd.wd5.myworkdayjobs.com/en-US/SearchJobs/job/Data---Analytics-Intern---Data-Solutions_R269314-1
๐ Nissan is Hiring !!
Role: Software Engineer I
Qualification: Bachelor's
Freshers can apply
Batch: 2024
Apply:
https://alliance.wd3.myworkdayjobs.com/en-US/nissanjobs/job/software-engineer-i_r00151957-1
Role: Software Engineer I
Qualification: Bachelor's
Freshers can apply
Batch: 2024
Apply:
https://alliance.wd3.myworkdayjobs.com/en-US/nissanjobs/job/software-engineer-i_r00151957-1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Walmart
Role: Software Engineer Intern
Batch eligible: 2024 passouts
Apply: https://bit.ly/3R3D5mO
Role: Software Engineer Intern
Batch eligible: 2024 passouts
Apply: https://bit.ly/3R3D5mO
๐1