#include <bits/stdc++.h>
using namespace std;
string nextBeautifulString(string s, int n, int k) {
for (int i = n - 1; i >= 0; --i) {
if (s[i] < 'a' + k - 1) {
s[i]++;
fill(s.begin() + i + 1, s.end(), 'a');
for (int j = 1; j < n; ++j) {
if (s[j] == s[j - 1] (j > 1 && s[j] == s[j - 2])) {
if (s[j] < 'a' + k - 1) {
s[j]++;
fill(s.begin() + j + 1, s.end(), 'a');
} else {
return "-1";
}
}
}
bool valid = true;
for (int j = 1; j < n; ++j) {
if (s[j] == s[j - 1] (j > 1 && s[j] == s[j - 2])) {
valid = false;
break;
}
}
if (valid) return s;
else return "-1";
}
}
return "-1";
}
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
string s;
cin >> n >> k >> s;
cout << nextBeautifulString(s, n, k) << endl;
}
return 0;
}
Beautiful Strings
Google โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Palo Alto Network
Role: Software Engineer
Batch eligible: 2025 grads
Apply: https://jobs.paloaltonetworks.com/en/job/-/-/47263/71837933584
Role: Software Engineer
Batch eligible: 2025 grads
Apply: https://jobs.paloaltonetworks.com/en/job/-/-/47263/71837933584
Paloaltonetworks
Explore Careers and Jobs in Cybersecurity at Palo Alto Networks
Palo Alto Networks is the global cybersecurity leader enabling secure digital transformation. Search our jobs to uncover your career in our global network.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
ACL Digital (An Alten Group Company) is hiring Freshers for Chennai Location.
Qualification - B.Tech/B.E-(CS, ECE, EEE) only
Experience 0-1 year
Mandatory skills - C, C++,embedded, linux, unit testing
Good to have - Python
Academics - above 70%
Interested candidates can share your resume to nishi.r@acldigital.com
Qualification - B.Tech/B.E-(CS, ECE, EEE) only
Experience 0-1 year
Mandatory skills - C, C++,embedded, linux, unit testing
Good to have - Python
Academics - above 70%
Interested candidates can share your resume to nishi.r@acldigital.com
int cleanupDataset(string dataset, int x, int y){
vector<int> F(26, 0);
for(char ch : dataset) F[ch - 'a']++;
int ans = 0;
if(x <= y){
int cnt = 0;
for(int num : F) ans += x * (num >> 1) , cnt += num & 1;
ans += y * (cnt >> 1);
}
else{
priority_queue<int> pq;
for(int num : F) if(num) pq.push(num);
while(pq.size() > 1){
int x1 = pq.top(); pq.pop();
int x2 = pq.top(); pq.pop();
int rem = min(x1, x2);
ans += y * rem;
if(max(x1, x2) - rem) pq.push(max(x1 , x2) - rem);
}
if(pq.size()){
int rem = pq.top(); pq.pop();
ans += x * (rem >> 1);
}
}
return ans;
}
Amazon โ
def findminimumvariance(n, height):
freq = {}
mini = float('inf')
for i in range(n):
if height[i] in freq:
s = freq[height[i]]
sub = i - s + 1
fir = height[s]
cnt = height[s:i + 1].count(fir)
var = sub - cnt
mini = min(mini, var)
freq[height[i]] = i
if mini == float('inf'):
return 0
return mini
Amazon โ
freq = {}
mini = float('inf')
for i in range(n):
if height[i] in freq:
s = freq[height[i]]
sub = i - s + 1
fir = height[s]
cnt = height[s:i + 1].count(fir)
var = sub - cnt
mini = min(mini, var)
freq[height[i]] = i
if mini == float('inf'):
return 0
return mini
Amazon โ
def getMaxEqualIndices(inv1, inv2):
n = len(inv1)
sinv1 = sum(inv1)
sinv2 = sorted(inv2)
prefixSum = [0] * (n + 1)
for i in range(n):
prefixSum[i + 1] = prefixSum[i] + sinv2[i]
left = 0
right = n
while left < right:
mid = (left + right + 1) // 2
if mid < n:
if prefixSum[mid] <= sinv1:
left = mid
else:
right = mid - 1
else:
if prefixSum[mid] == sinv1:
left = mid
else:
right = mid - 1
return left
Amazon โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
News Corp is hiring for Graduate Engineer Trainee
Experience: 0 - 1 year's
Apply here: https://dowjones.wd1.myworkdayjobs.com/News_Corp_Careers/job/Bangalore/Graduate-Engineer-Trainee_Job_Req_43522
Experience: 0 - 1 year's
Apply here: https://dowjones.wd1.myworkdayjobs.com/News_Corp_Careers/job/Bangalore/Graduate-Engineer-Trainee_Job_Req_43522
Amazon sending interview mail โ
def func(logs,maxSpan):
sigins = {}
signouts = {}
for i in logs:
iid,time,string = i.split()
if string == "sign-out":
signouts[iid] = int(time)
else:
sigins[iid] = int(time)
l = []
for i,j in signouts.items():
if i in sigins:
time = j - sigins[i]
if time <= maxSpan:
l.append(int(i))
l.sort()
res = [str(i) for i in l]
return res
Sign-in sign -out Logs โ
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long maximizeTotalMemoryPoints(vector<int> memory) {
sort(memory.begin(), memory.end(), & -> bool {
return a > b;
});
ll total = 0;
ll cs = 0;
for(auto m : memory){
cs += m;
total += cs;
}
return total;
}
int main(){
int n;
cin >> n;
vector<int> memory(n);
for(int &x: memory) cin >> x;
cout << maximizeTotalMemoryPoints(memory);
}
Amazon โ
using namespace std;
typedef long long ll;
long maximizeTotalMemoryPoints(vector<int> memory) {
sort(memory.begin(), memory.end(), & -> bool {
return a > b;
});
ll total = 0;
ll cs = 0;
for(auto m : memory){
cs += m;
total += cs;
}
return total;
}
int main(){
int n;
cin >> n;
vector<int> memory(n);
for(int &x: memory) cin >> x;
cout << maximizeTotalMemoryPoints(memory);
}
Amazon โ
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int min_memory_after_deletion(vector<int>& a, int b) {
int cd = accumulate(a.begin(), a.end(), 0);
int n = a.size();
if (b > n) {
return cd;
}
int max_segment_sum = 0;
int current_segment_sum = accumulate(a.begin(), a.begin() + b, 0);
for (int i = 0; i <= n - b; ++i) {
max_segment_sum = max(max_segment_sum, current_segment_sum);
if (i + b < n) {
current_segment_sum = current_segment_sum - a[i] + a[i + b];
}
}
max_segment_sum = max(max_segment_sum, current_segment_sum);
return cd - max_segment_sum;
}
Amazon โ
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int min_memory_after_deletion(vector<int>& a, int b) {
int cd = accumulate(a.begin(), a.end(), 0);
int n = a.size();
if (b > n) {
return cd;
}
int max_segment_sum = 0;
int current_segment_sum = accumulate(a.begin(), a.begin() + b, 0);
for (int i = 0; i <= n - b; ++i) {
max_segment_sum = max(max_segment_sum, current_segment_sum);
if (i + b < n) {
current_segment_sum = current_segment_sum - a[i] + a[i + b];
}
}
max_segment_sum = max(max_segment_sum, current_segment_sum);
return cd - max_segment_sum;
}
Amazon โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Clearfeed is hiring SWE intern
For 2025 grads
Location: Bangalore
https://clearfeed.keka.com/careers/jobdetails/798
For 2025 grads
Location: Bangalore
https://clearfeed.keka.com/careers/jobdetails/798
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Winter Internships for college students :
1. FOSSEE : https://fossee.in/winter-internship/2024
2. IIT Bhubaneshwar : https://webapps.iitbbs.ac.in/internship-application/,
3. NPTEL : https://archive.nptel.ac.in/internship/
4. JNCASR : https://www.jncasr.ac.in/winterschool/
5. ACM: https://india.acm.org/education/acm-india-winter-schools-2023-24
ACM: Association for Computing Machinery
JNCASR: Jawaharlal Nehru Centre For Advanced Scientific Research
Apply for these asap.
1. FOSSEE : https://fossee.in/winter-internship/2024
2. IIT Bhubaneshwar : https://webapps.iitbbs.ac.in/internship-application/,
3. NPTEL : https://archive.nptel.ac.in/internship/
4. JNCASR : https://www.jncasr.ac.in/winterschool/
5. ACM: https://india.acm.org/education/acm-india-winter-schools-2023-24
ACM: Association for Computing Machinery
JNCASR: Jawaharlal Nehru Centre For Advanced Scientific Research
Apply for these asap.
webapps.iitbbs.ac.in
Internship Application | IIT Bhubaneswar
Internship Application at IIT Bhubaneswar
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Propel hiring Software Developer
2025 batch passouts
Apply Here : https://talent.propelinc.com/jobs/Careers/26698000080989011/Fresher-2025-Batch-Software-Developer?source=CareerSite
2025 batch passouts
Apply Here : https://talent.propelinc.com/jobs/Careers/26698000080989011/Fresher-2025-Batch-Software-Developer?source=CareerSite
Propel
Propel - Fresher (2025 Batch) | Software Developer in Chennai
Propel Requisites Details Role Name / Role Title Developer Experience range Fresher - 2025 batch pass-out Expected Skill 1. Strong fundamentals of pr
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Moody's hiring for Software Engineer
0-3 year experience
Apply Here : https://careers.moodys.com/associate-software-engineer/job/28622865
0-3 year experience
Apply Here : https://careers.moodys.com/associate-software-engineer/job/28622865
Moodys
Associate Software Engineer job in Gurugram, HR with Moody's
Join Moody's in Gurugram, Haryana by applying to the Associate Software Engineer job today! Start your career in Gurugram, Haryana now!
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Syncron is hiring Machine Learning Engineer
For 2021, 2022 grads
Location: Bangalore
https://careers.syncron.com/jobs/4697093-machine-learning-engineer
For 2021, 2022 grads
Location: Bangalore
https://careers.syncron.com/jobs/4697093-machine-learning-engineer
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Internship opportunity for 2024,2025,2026 batch students
Company: Centre for Development of Telematics (C-D0T)
Eligibility: B.Tech/BE students (CS/EC) who have completed their second-year exams with a minimum CGPA of 7.0 or 70%.
Duration: Minimum 3 months to a maximum of 1 year. Stipend: 50,000/month + access to subsidized facilities.
Interview location: Bangalore/Delhi last date:31 Oct 2024.
Submit your CV and application form to internship@cdot.in
Shortlisted candidates will be called for an interview.
Company: Centre for Development of Telematics (C-D0T)
Eligibility: B.Tech/BE students (CS/EC) who have completed their second-year exams with a minimum CGPA of 7.0 or 70%.
Duration: Minimum 3 months to a maximum of 1 year. Stipend: 50,000/month + access to subsidized facilities.
Interview location: Bangalore/Delhi last date:31 Oct 2024.
Submit your CV and application form to internship@cdot.in
Shortlisted candidates will be called for an interview.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Tower Research Capital
Role: ML Intern
Batch eligible: 2025 and 2026 grads
Apply: https://tower-research.com/open-positions/?gh_jid=6114125
Role: ML Intern
Batch eligible: 2025 and 2026 grads
Apply: https://tower-research.com/open-positions/?gh_jid=6114125
Tower Research Capital
open-positions - Tower Research Capital
Explore open positions at Tower Research Capital and start the next chapter of your career in quantitative trading, engineering, and more.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Scaler
Role: Problem setter and Content Reviewer Intern
Batch eligible: 2025 and 2026 grads
Apply: https://docs.google.com/forms/d/e/1FAIpQLSf0nNjeH0m0x_87lGk8dVxmqI4mgt3_1U_WMCiotaiCUBREkw/viewform
Role: Problem setter and Content Reviewer Intern
Batch eligible: 2025 and 2026 grads
Apply: https://docs.google.com/forms/d/e/1FAIpQLSf0nNjeH0m0x_87lGk8dVxmqI4mgt3_1U_WMCiotaiCUBREkw/viewform