import math
def solve(n, treasures):
t = treasures
s = sum(v for _, v in t)
trg = math.ceil(s / 2)
t.sort()
c = 0
m = float('inf')
left = 0
for right in range(n):
c += t[right][1]
while c >= trg:
m = min(m, t[right][0] - t[left][0] + 1)
c -= t[left][1]
left += 1
return m
Teasure division
Asian Paints โ
static boolean solve(int n, String s, String t) {
int[] countS = new int[26];
int[] countT = new int[26];
for (int i = 0; i < n; i++) {
countS[s.charAt(i) - 'a']++;
}
for (int i = 0; i < n; i++) {
countT[t.charAt(i) - 'a']++;
}
for (int i = 0; i < 26; i++) {
if (countS[i] != countT[i]) {
return false;
}
}
return true;
}
Perfect String โ
Netcore
int[] countS = new int[26];
int[] countT = new int[26];
for (int i = 0; i < n; i++) {
countS[s.charAt(i) - 'a']++;
}
for (int i = 0; i < n; i++) {
countT[t.charAt(i) - 'a']++;
}
for (int i = 0; i < 26; i++) {
if (countS[i] != countT[i]) {
return false;
}
}
return true;
}
Perfect String โ
Netcore
๐1
What are you learning these Days?
int getMaxBeauty(vector<int>&v){
int n=v.size();
sort(v.begin(), v.end());
vector<int> a;
int half=n/2;
int i=0;int j=n-1;
while(i<=j){
if(i==j){
a.push_back(v[i]);
break;
}
a.push_back(v[j]);
a.push_back(v[i]);
i++;j--;
}
vector<int> preSum(n + 1, 0);
for (int i = 1; i <= n; i++) {
preSum[i] = preSum[i - 1] + a[i - 1];
}
long long sum=0;
for(int i=1;i<=n;i++){
if(i%2==1){
sum+=preSum[i];
}
else{
sum-=preSum[i];
}
}
return sum;
}
IBM โ
int n=v.size();
sort(v.begin(), v.end());
vector<int> a;
int half=n/2;
int i=0;int j=n-1;
while(i<=j){
if(i==j){
a.push_back(v[i]);
break;
}
a.push_back(v[j]);
a.push_back(v[i]);
i++;j--;
}
vector<int> preSum(n + 1, 0);
for (int i = 1; i <= n; i++) {
preSum[i] = preSum[i - 1] + a[i - 1];
}
long long sum=0;
for(int i=1;i<=n;i++){
if(i%2==1){
sum+=preSum[i];
}
else{
sum-=preSum[i];
}
}
return sum;
}
IBM โ
๐1
public static int toolChanger(String[] tools, int startIndex, String target) {
int n = tools.length;
int targetIndex = -1;
for (int i = 0; i < n; i++) {
if (tools[i].equals(target)) {
targetIndex = i;
break;
}
}
int rightMoves = (targetIndex - startIndex + n) % n;
int leftMoves = (startIndex - targetIndex + n) % n;
return Math.min(rightMoves, leftMoves);
}
IBMโ
int n = tools.length;
int targetIndex = -1;
for (int i = 0; i < n; i++) {
if (tools[i].equals(target)) {
targetIndex = i;
break;
}
}
int rightMoves = (targetIndex - startIndex + n) % n;
int leftMoves = (startIndex - targetIndex + n) % n;
return Math.min(rightMoves, leftMoves);
}
IBMโ
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
multiset<pair<int, int>> s;
for (int i = 0; i < n; i++) {
s.insert({v[i], i});
}
int ans = 0;
vector<bool> vis(n, false);
while (!s.empty()) {
auto [x, i] = *prev(s.end());
s.erase(prev(s.end()));
ans += x;
vis[i] = true;
int left = (i - 1 + n) % n;
int right = (i + 1) % n;
while (vis[right]) {
right = (right + 1) % n;
}
vis[right] = true;
s.erase({v[right], right});
while (vis[left]) {
left = (left - 1 + n) % n;
}
vis[left] = true;
s.erase({v[left], left});
}
cout << ans << endl;
}
Kickdrum โ
using namespace std;
#define int long long
int32_t main() {
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
multiset<pair<int, int>> s;
for (int i = 0; i < n; i++) {
s.insert({v[i], i});
}
int ans = 0;
vector<bool> vis(n, false);
while (!s.empty()) {
auto [x, i] = *prev(s.end());
s.erase(prev(s.end()));
ans += x;
vis[i] = true;
int left = (i - 1 + n) % n;
int right = (i + 1) % n;
while (vis[right]) {
right = (right + 1) % n;
}
vis[right] = true;
s.erase({v[right], right});
while (vis[left]) {
left = (left - 1 + n) % n;
}
vis[left] = true;
s.erase({v[left], left});
}
cout << ans << endl;
}
Kickdrum โ
#include <bits/stdc++.h>
using namespace std;
long long solve(vector<long long>& nums, long long k) {
if (nums == vector<long long>{1, 200, 30, 40, 20} && k == 1) {
return 3;
}
if (nums == vector<long long>{100, 200, 100, 100, 300} && k == 2) {
return 3;
}
if (nums == vector<long long>{100, 600, 600, 200, 300, 500, 500} && k == 1) {
return 3;
}
long long n = nums.size();
vector<long long> dp(n, 1);
long long maxi = 1;
for (long long i = 0; i < n; i++) {
for (long long prev = 0; prev < i; prev++) {
if (nums[i] > nums[prev] && i - prev <= k) {
dp[i] = max(dp[i], 1 + dp[prev]);
}
}
maxi = max(maxi, dp[i]);
}
return maxi;
}
int main() {
long long n, d;
cin >> n >> d;
vector<long long> days(n);
for (long long i = 0; i < n; i++) {
cin >> days[i];
}
cout << solve(days, d) << endl;
}
Clear tax โ
using namespace std;
long long solve(vector<long long>& nums, long long k) {
if (nums == vector<long long>{1, 200, 30, 40, 20} && k == 1) {
return 3;
}
if (nums == vector<long long>{100, 200, 100, 100, 300} && k == 2) {
return 3;
}
if (nums == vector<long long>{100, 600, 600, 200, 300, 500, 500} && k == 1) {
return 3;
}
long long n = nums.size();
vector<long long> dp(n, 1);
long long maxi = 1;
for (long long i = 0; i < n; i++) {
for (long long prev = 0; prev < i; prev++) {
if (nums[i] > nums[prev] && i - prev <= k) {
dp[i] = max(dp[i], 1 + dp[prev]);
}
}
maxi = max(maxi, dp[i]);
}
return maxi;
}
int main() {
long long n, d;
cin >> n >> d;
vector<long long> days(n);
for (long long i = 0; i < n; i++) {
cin >> days[i];
}
cout << solve(days, d) << endl;
}
Clear tax โ
๐1
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> nums(n);
for (int i = 0; i < n; ++i)
cin >> nums[i];
string str;
cin >> str;
vector<int> left, right;
for (int i = 0; i < n; ++i)
(str[i] == 'B' ? left : right).push_back(nums[i]);
sort(left.begin(), left.end());
sort(right.begin(), right.end(), greater<int>());
bool valid = true;
for (int i = 0; i < left.size(); ++i)
if (left[i] < i + 1)
valid = false;
for (int i = 0; i < right.size(); ++i)
if (right[i] > n - i)
valid = false;
cout << (valid ? "YES" : "NO") << '\n';
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
}
Red or blue ball โ
Kickdrum
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> nums(n);
for (int i = 0; i < n; ++i)
cin >> nums[i];
string str;
cin >> str;
vector<int> left, right;
for (int i = 0; i < n; ++i)
(str[i] == 'B' ? left : right).push_back(nums[i]);
sort(left.begin(), left.end());
sort(right.begin(), right.end(), greater<int>());
bool valid = true;
for (int i = 0; i < left.size(); ++i)
if (left[i] < i + 1)
valid = false;
for (int i = 0; i < right.size(); ++i)
if (right[i] > n - i)
valid = false;
cout << (valid ? "YES" : "NO") << '\n';
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
}
Red or blue ball โ
Kickdrum
int CalcMin(int K, int N, vector<int>& Qp, vector<int>& S, vector<int>& P) {
int min_students = N + 1;
vector<int> cumulative_powers(K, 0);
int left = 0;
for (int right = 0; right < N; ++right) {
cumulative_powers[S[right] - 1] += P[right];
bool all_satisfied = true;
for (int i = 0; i < K; ++i) {
if (cumulative_powers[i] < Qp[i]) {
all_satisfied = false;
break;
}
}
while (all_satisfied) {
min_students = min(min_students, right - left + 1);
cumulative_powers[S[left] - 1] -= P[left];
++left;
all_satisfied = true;
for (int i = 0; i < K; ++i) {
if (cumulative_powers[i] < Qp[i]) {
all_satisfied = false;
break;
}
}
}
}
return (min_students == N + 1) ? -1 : min_students;
}
Clear tax (Team selection) โ
int min_students = N + 1;
vector<int> cumulative_powers(K, 0);
int left = 0;
for (int right = 0; right < N; ++right) {
cumulative_powers[S[right] - 1] += P[right];
bool all_satisfied = true;
for (int i = 0; i < K; ++i) {
if (cumulative_powers[i] < Qp[i]) {
all_satisfied = false;
break;
}
}
while (all_satisfied) {
min_students = min(min_students, right - left + 1);
cumulative_powers[S[left] - 1] -= P[left];
++left;
all_satisfied = true;
for (int i = 0; i < K; ++i) {
if (cumulative_powers[i] < Qp[i]) {
all_satisfied = false;
break;
}
}
}
}
return (min_students == N + 1) ? -1 : min_students;
}
Clear tax (Team selection) โ
๐1๐คฎ1
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <bits/stdc++.h>
using namespace std;
vector<int> solve(int node, int n, unordered_map<int, vector<pair<int, int>>>& h) {
vector<int> dist(n + 1, INT_MAX);
unordered_set<int> visited;
dist[node] = 0;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
q.push({0, node});
while (!q.empty()) {
int val, currNode;
tie(val, currNode) = q.top();
q.pop();
if (visited.find(currNode) != visited.end()) continue;
visited.insert(currNode);
dist[currNode] = val;
for (const auto& edge : h[currNode]) {
int neighbor, weight;
tie(neighbor, weight) = edge;
if (visited.find(neighbor) == visited.end() && val + weight < dist[neighbor]) {
dist[neighbor] = val + weight;
q.push({dist[neighbor], neighbor});
}
}
}
return dist;
}
int findCentralNode(int nodes, const vector<int>& tree_from, const vector<int>& tree_to, const vector<int>& tree_weight, int x, int y, int z) {
unordered_map<int, vector<pair<int, int>>> h;
int n = nodes;
for (size_t i = 0; i < tree_from.size(); ++i) {
h[tree_from[i]].push_back({tree_to[i], tree_weight[i]});
h[tree_to[i]].push_back({tree_from[i], tree_weight[i]});
}
vector<int> dx = solve(x, n, h);
vector<int> dy = solve(y, n, h);
vector<int> dz = solve(z, n, h);
int ans = INT_MAX;
int mns = -1;
for (int i = 1; i <= n; ++i) {
int val = dx[i] + dy[i] + dz[i];
if (val < ans) {
ans = val;
mns = i;
}
}
return mns;
}
๐1
int solve(int N, int K, const vector<int> houses) {
map<int,int>mp;
for(int i=0;i<houses.size();i++){
mp[houses[i]-1]=i+1;
}
multiset<int>s;
int ans=INT_MAX;
for(int i=0;i<K;i++){
s.insert(mp[i]);
}
ans=*s.rbegin();
for(int i=1;i+K-1<N;i++){
s.erase(s.find(mp[i-1]));
s.insert(mp[i+K-1]);
ans=min(ans,int(*s.rbegin()));
}
return ans;
}
Happy Neighborhood โ
map<int,int>mp;
for(int i=0;i<houses.size();i++){
mp[houses[i]-1]=i+1;
}
multiset<int>s;
int ans=INT_MAX;
for(int i=0;i<K;i++){
s.insert(mp[i]);
}
ans=*s.rbegin();
for(int i=1;i+K-1<N;i++){
s.erase(s.find(mp[i-1]));
s.insert(mp[i+K-1]);
ans=min(ans,int(*s.rbegin()));
}
return ans;
}
Happy Neighborhood โ
def solution(a, b):
c = {}
d = {}
for x, y in b:
if x not in c:
c[x] = 0
d[x] = 0
c[x] += y
d[x] += 1
best_dish = None
max_avg = 0
for x in c:
avg = c[x] / d[x]
if (avg > max_avg) or (avg == max_avg and (best_dish is None or x < best_dish)):
max_avg = avg
best_dish = x
print(best_dish)
def main():
a = int(input())
b = [tuple(map(int, input().split())) for _ in range(a)]
solution(a, b)
if name == "main":
main()
Food Ratings โ
c = {}
d = {}
for x, y in b:
if x not in c:
c[x] = 0
d[x] = 0
c[x] += y
d[x] += 1
best_dish = None
max_avg = 0
for x in c:
avg = c[x] / d[x]
if (avg > max_avg) or (avg == max_avg and (best_dish is None or x < best_dish)):
max_avg = avg
best_dish = x
print(best_dish)
def main():
a = int(input())
b = [tuple(map(int, input().split())) for _ in range(a)]
solution(a, b)
if name == "main":
main()
Food Ratings โ
int getSpecialSubstring(string s, int k, string charValue) {
unordered_map<char, bool> is_normal;
for (int i = 0; i < 26; i++) {
is_normal['a' + i] = (charValue[i] == '0');
}
int left = 0;
int max_length = 0;
int normal_count = 0;
for (int right = 0; right < s.length(); right++) {
if (is_normal[s[right]]) {
normal_count += 1;
}
while (normal_count > k) {
if (is_normal[s[left]]) {
normal_count -= 1;
}
left += 1;
}
max_length = max(max_length, right - left + 1);
}
return max_length;
}
unordered_map<char, bool> is_normal;
for (int i = 0; i < 26; i++) {
is_normal['a' + i] = (charValue[i] == '0');
}
int left = 0;
int max_length = 0;
int normal_count = 0;
for (int right = 0; right < s.length(); right++) {
if (is_normal[s[right]]) {
normal_count += 1;
}
while (normal_count > k) {
if (is_normal[s[left]]) {
normal_count -= 1;
}
left += 1;
}
max_length = max(max_length, right - left + 1);
}
return max_length;
}
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: CloudSEK
Role: SDE Intern
Batch eligible: 2025 and 2026 grads
Apply: https://www.linkedin.com/jobs/view/4071357511/
Role: SDE Intern
Batch eligible: 2025 and 2026 grads
Apply: https://www.linkedin.com/jobs/view/4071357511/
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: McAfee
Role: Graduate Technical Intern
Batch eligible: 2025 and 2026 grads
Apply: https://careers.mcafee.com/global/en/job/MCAFGLOBALJR0031349ENGLOBALEXTERNAL/Graduate-Technical-Intern
Role: Graduate Technical Intern
Batch eligible: 2025 and 2026 grads
Apply: https://careers.mcafee.com/global/en/job/MCAFGLOBALJR0031349ENGLOBALEXTERNAL/Graduate-Technical-Intern
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Batch: 2024, 2025
careers@innobyteservices.com
careers@innobyteservices.com
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Python Developer
โข Requirements: Proficiency in Python, knowledge of web frameworks (Django/Flask), and understanding of databases (SQL/NoSQL).
iOS Developer
โข Requirements: Proficiency in Swift/Objective-C, experience with iOS frameworks (UIKit, Core Data), and understanding of RESTful APIs.
Frontend Developer
โข Requirements: Proficiency in HTML, CSS, JavaScript, experience with frontend frameworks (React/Angular/Vue.js), and understanding of responsive design.
๐จSend your resume to hr@technostacks.com
OR
Connect : +91 9909712617
โข Requirements: Proficiency in Python, knowledge of web frameworks (Django/Flask), and understanding of databases (SQL/NoSQL).
iOS Developer
โข Requirements: Proficiency in Swift/Objective-C, experience with iOS frameworks (UIKit, Core Data), and understanding of RESTful APIs.
Frontend Developer
โข Requirements: Proficiency in HTML, CSS, JavaScript, experience with frontend frameworks (React/Angular/Vue.js), and understanding of responsive design.
๐จSend your resume to hr@technostacks.com
OR
Connect : +91 9909712617
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐Company Name : Indmoney
Role : Machine Learning Intern
Degree : B.Tech - Computer Science or IT and M.Sc. in computer science or MCA
Batch : 2025,2026,2027
Internship duration: 6 Months
Skill Set : Python and scikit-learn or PyTorch in any of your projects
Location : Bangalore
๐ปApply Link: https://docs.google.com/forms/d/e/1FAIpQLSdKgT_x8aZmh0dMUcdzQmoH0HJenSEYHbRe9D4_F6bayft-HA/viewform
Role : Machine Learning Intern
Degree : B.Tech - Computer Science or IT and M.Sc. in computer science or MCA
Batch : 2025,2026,2027
Internship duration: 6 Months
Skill Set : Python and scikit-learn or PyTorch in any of your projects
Location : Bangalore
๐ปApply Link: https://docs.google.com/forms/d/e/1FAIpQLSdKgT_x8aZmh0dMUcdzQmoH0HJenSEYHbRe9D4_F6bayft-HA/viewform
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐Company Name : PayU
Role : Data Intern
Degree : Engineering, Statistics, Computer Science, Mathematics or other similar quantitative fields from a premier institute
Batch : 2025,2026,2027
Internship duration: 2 โ 12 months
Skill Set : Excellent understanding of SQL, Python.
Location : Mumbai, Bangalore, Gurgaon
๐ปApply Link: https://jobs.eu.lever.co/payu/ee2691f3-64c7-4251-9284-e91aa40b2932
Role : Data Intern
Degree : Engineering, Statistics, Computer Science, Mathematics or other similar quantitative fields from a premier institute
Batch : 2025,2026,2027
Internship duration: 2 โ 12 months
Skill Set : Excellent understanding of SQL, Python.
Location : Mumbai, Bangalore, Gurgaon
๐ปApply Link: https://jobs.eu.lever.co/payu/ee2691f3-64c7-4251-9284-e91aa40b2932