#include <bits/stdc++.h>
using namespace std;
int solve(const string& num) {
char mini = '9';
char maxi = '0';
for (char digit : num) {
if (digit > maxi) maxi = digit;
if (digit < mini) mini = digit;
}
int sum = 0;
for (char digit : num) {
if (digit != maxi && digit != mini) {
sum += digit - '0';
}
}
return sum;
}
int main() {
int N;
cin >> N;
vector<int> v(N);
for (int i = 0; i < N; ++i) {
cin >> v[i];
}
int total = 0;
for (int num : v) {
total += solve(to_string(num));
}
cout << total << endl;
return 0;
}
Browserstack โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> calculateRanks(const vector<int>& leaderboard, const vector<int>& attempts) {
vector<int> ranks;
vector<int> uniqueScores = leaderboard;
uniqueScores.erase(unique(uniqueScores.begin(), uniqueScores.end()), uniqueScores.end());
int n = uniqueScores.size();
for (int score : attempts) {
while (n > 0 && score >= uniqueScores[n-1]) {
n--;
}
ranks.push_back(n + 1);
}
return ranks;
}
int main() {
int s;
cin >> s;
vector<int> leaderboard(s);
for (int i = 0; i < s; ++i) {
cin >> leaderboard[i];
}
int x;
cin >> x;
vector<int> attempts(x);
for (int i = 0; i < x; ++i) {
cin >> attempts[i];
}
vector<int> ranks = calculateRanks(leaderboard, attempts);
for (int rank : ranks) {
cout << rank << " ";
}
cout << endl;
return 0;
}
Browserstack โ
int minCacheSize(int n, const vector<string>& reqs, int k){
auto getHits = [&](int sz) {
unordered_set<string> cache;
list<string> order;
int hits = 0;
for (const string& item : reqs) {
if (cache.find(item) != cache.end()) {
hits++;
order.erase(find(order.begin(), order.end(), item));
order.push_front(item);
}
else {
if (cache.size() == sz) {
cache.erase(order.back());
order.pop_back();
}
cache.insert(item);
order.push_front(item);
}
}
return hits;
};
int l = 1, r = n, res = -1;
while (l <= r) {
int m = l + (r - l) / 2;
if (getHits(m) >= k) {
res = m;
r = m - 1;
} else {
l = m + 1;
}
}
return res;
}
ion mincachesizeโ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Paisabazaar.com is hiring Software Engineer
For 2021, 2022, 2023, 2024 grads
Location: Gurugram
https://forms.gle/pB5UsHKejjb4MV3e6
For 2021, 2022, 2023, 2024 grads
Location: Gurugram
https://forms.gle/pB5UsHKejjb4MV3e6
#include <bits/stdc++.h>
using namespace std;
struct Node {
int data;
Node *left, *right;
Node(int x) : data(x), left(nullptr), right(nullptr) {}
};
int solve(Node* root, int &maxi) {
if (root == NULL) return INT_MAX;
if (root->left == NULL && root->right == NULL) return root->data;
int left = solve(root->left, maxi);
int right = solve(root->right, maxi);
if (left != INT_MAX) maxi = max(maxi, root->data - left);
if (right != INT_MAX) maxi = max(maxi, root->data - right);
return min(root->data, min(left, right));
}
int maxDiff(Node* root) {
if (root == NULL) return 0;
int maxi = INT_MIN;
solve(root, maxi);
return maxi;
}
Node* buildTree(const vector<int>& levelOrder) {
if (levelOrder.empty() || levelOrder[0] == -1) return nullptr;
Node* root = new Node(levelOrder[0]);
queue<Node*> q;
q.push(root);
int index = 1;
while (!q.empty() && index < levelOrder.size()) {
Node* node = q.front();
q.pop();
if (index < levelOrder.size() && levelOrder[index] != -1) {
node->left = new Node(levelOrder[index]);
q.push(node->left);
}
index++;
if (index < levelOrder.size() && levelOrder[index] != -1) {
node->right = new Node(levelOrder[index]);
q.push(node->right);
}
index++;
}
return root;
}
int main() {
int height;
cin >> height;
vector<int> levelOrder;
int value;
while (cin >> value) {
levelOrder.push_back(value);
}
if (height == 0 levelOrder.empty() (levelOrder.size() == 1 && levelOrder[0] == -1)) {
cout << 0 << endl;
return 0;
}
Node* root = buildTree(levelOrder);
int result = maxDiff(root);
cout << result << endl;
return 0;
}
nodes and their ancestor Samsungโ
#include <bits/stdc++.h>
using namespace std;
struct TreeNode {
int val;
TreeNode *left, *right;
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
};
TreeNode* buildTree(const vector<string>& levelOrder) {
if (levelOrder.empty() || levelOrder[0] == "-1") return nullptr;
TreeNode* root = new TreeNode(stoi(levelOrder[0]));
queue<TreeNode*> q;
q.push(root);
int index = 1;
while (!q.empty() && index < levelOrder.size()) {
TreeNode* node = q.front();
q.pop();
if (index < levelOrder.size() && levelOrder[index] != "-1") {
node->left = new TreeNode(stoi(levelOrder[index]));
q.push(node->left);
}
index++;
if (index < levelOrder.size() && levelOrder[index] != "-1") {
node->right = new TreeNode(stoi(levelOrder[index]));
q.push(node->right);
}
index++;
}
return root;
}
int sumOfNodesWithoutSiblings(TreeNode* root) {
if (!root) return -1;
queue<TreeNode*> q;
q.push(root);
int sum = 0;
while (!q.empty()) {
TreeNode* node = q.front();
q.pop();
if ((node->left && !node->right) || (!node->left && node->right)) {
sum += node->left ? node->left->val : node->right->val;
}
if (node->left) {
q.push(node->left);
}
if (node->right) {
q.push(node->right);
}
}
return sum == 0 ? -1 : sum;
}
int main() {
int height;
cin >> height;
vector<string> levelOrder;
string value;
while (cin >> value) {
levelOrder.push_back(value);
}
if (height == 0 levelOrder.empty() (levelOrder.size() == 1 && levelOrder[0] == "-1")) {
cout << -1 << endl;
return 0;
}
TreeNode* root = buildTree(levelOrder);
int result = sumOfNodesWithoutSiblings(root);
cout << result << endl;
return 0;
}
no sibling node
Samsungโ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <bits/stdc++.h>
using namespace std;
class UnionFind {
vector<int> parent, rank;
public:
UnionFind(int n) {
parent.resize(n);
iota(parent.begin(), parent.end(), 0);
rank.resize(n, 0);
}
int find(int u) {
if (u != parent[u])
parent[u] = find(parent[u]);
return parent[u];
}
void unite(int u, int v) {
int rootU = find(u);
int rootV = find(v);
if (rootU != rootV) {
if (rank[rootU] > rank[rootV])
parent[rootV] = rootU;
else if (rank[rootU] < rank[rootV])
parent[rootU] = rootV;
else {
parent[rootV] = rootU;
rank[rootU]++;
}
}
}
};
int solve(int n, int c_service, int c_link, vector<pair<int, int>>& pairs) {
UnionFind uf(n);
for (auto& p : pairs) {
uf.unite(p.first - 1, p.second - 1);
}
vector<bool> conn(n, false);
int cnt = 0;
for (int i = 0; i < n; i++) {
int root = uf.find(i);
if (!conn[root]) {
conn[root] = true;
cnt++;
}
}
int op1 = n * c_service;
int op2 = cnt * c_service + (n - cnt) * c_link;
return min(op1,op2);
}
int main() {
int n, c_service, c_link, numPairs;
cin >> n >> numPairs >> c_service >> c_link;
vector<pair<int, int>> pairs(numPairs);
for (int i = 0; i < numPairs; i++) {
cin >> pairs[i].first >> pairs[i].second;
}
int minCost = solve(n, c_service, c_link, pairs);
cout << minCost << endl;
return 0;
}
IBMโ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐Hiring!!
Work From Home - Fresher
QA Engineer (Manual testing) who can join us immediately.
Eligiblity: Fresher
Interested candidates can share their cv on
himanshi@wizni.com
Work From Home - Fresher
QA Engineer (Manual testing) who can join us immediately.
Eligiblity: Fresher
Interested candidates can share their cv on
himanshi@wizni.com
Company Name : NTT Data
Role : Associate Software Engineer
Batch : 2024/2023/2022 passouts
Link : https://careers.services.global.ntt/global/en/job/NTT1GLOBALR117718EXTERNALENGLOBAL/Associate-Software-Development-Engineer
Role : Associate Software Engineer
Batch : 2024/2023/2022 passouts
Link : https://careers.services.global.ntt/global/en/job/NTT1GLOBALR117718EXTERNALENGLOBAL/Associate-Software-Development-Engineer
#include <bits/stdc++.h>
using namespace std;
bool canForm(int m, int k) {
return m >= k * (k - 1);
}
int solve(int n, int m) {
int l = 1, r = n;
int res = 1;
while (l <= r) {
int mid = l + (r - l) / 2;
if (canForm(m, mid)) {
res = mid;
l = mid + 1;
} else {
r = mid - 1;
}
}
return res;
}
int main() {
int n, m;
cin >> n >> m;
int ans = solve(n, m);
cout << ans<< endl;
return 0;
}
IBMโ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Jade Global is organising a Walkin Interview for 2024 Graduates (No Post-Graduates) โค๏ธโค๏ธโค๏ธ
Stream:
BSc (CS / IT / Stats / Maths / Physics / Electronics)
BCA
BBA-CA (Freshers)
Year of passing: 2024
60% Overall.
Joining: By Mid September
Opportunities
1. Sponsered MSc and MTech Degree from BITS Pilani.
2. Technical and Self- Development Program.
Drive: Monday to Friday (Coming Week) from 10 AM to 12 Noon.
Venue: Wadgaonsheri Office, Nyati Tech Park, 7th Floor, Near Brahma Suncity, Behind Nyati Meadows, Wadgaon Sheri Pune- 411014
Stream:
BSc (CS / IT / Stats / Maths / Physics / Electronics)
BCA
BBA-CA (Freshers)
Year of passing: 2024
60% Overall.
Joining: By Mid September
Opportunities
1. Sponsered MSc and MTech Degree from BITS Pilani.
2. Technical and Self- Development Program.
Drive: Monday to Friday (Coming Week) from 10 AM to 12 Noon.
Venue: Wadgaonsheri Office, Nyati Tech Park, 7th Floor, Near Brahma Suncity, Behind Nyati Meadows, Wadgaon Sheri Pune- 411014
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Clearfeed
Role: Software Engineer Intern
Batch eligible: 2025 grads only
Apply: https://clearfeed.keka.com/careers/jobdetails/150
Role: Software Engineer Intern
Batch eligible: 2025 grads only
Apply: https://clearfeed.keka.com/careers/jobdetails/150
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Akamai Technology
Role: Software Engineer (Remote)
Batch eligible: 2023 and 2024 grads
Apply: https://akamaicareers.inflightcloud.com/jobdetails/aka_ext/035360
Role: Software Engineer (Remote)
Batch eligible: 2023 and 2024 grads
Apply: https://akamaicareers.inflightcloud.com/jobdetails/aka_ext/035360
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Amgen is hiring Associate Software Engineer
For 2021, 2022, 2023, 2024 grads
Location: Hyderabad
https://careers.amgen.com/en/job/hyderabad/associate-software-engineer/87/68552403264
For 2021, 2022, 2023, 2024 grads
Location: Hyderabad
https://careers.amgen.com/en/job/hyderabad/associate-software-engineer/87/68552403264
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
#include <iostream>.
#include <vector>
#include <deque>
#include <climits>
#include <algorithm>
int solve(int N, int K, const std::vector<int>& houses) {
vector<int> indices(N);
for (int i = 0; i < houses.size(); i++) {
indices[houses[i] - 1] = i + 1;
}
deque<int> maxDeque;
int ans = INT_MAX;
for (int i = 0; i < K; i++) {
while (!maxDeque.empty() && indices[i] >= indices[maxDeque.back()]) {
maxDeque.pop_back();
}
maxDeque.push_back(i);
}
ans = indices[maxDeque.front()];
for (int i = K; i < N; i++) {
if (maxDeque.front() <= i - K) {
maxDeque.pop_front();
}
while (!maxDeque.empty() && indices[i] >= indices[maxDeque.back()]) {
maxDeque.pop_back();
}
maxDeque.push_back(i);
ans = std::min(ans, indices[maxDeque.front()]);
}
return ans;
}
UC Happy Neighborhood โ