allcoding1
def cardinalitySort(nums): return sorted(nums, key=lambda num: [bin(num).count('1'), num]) Cardinality sorting
#include <bits/stdc++.h>
using namespace std;
bool checkbit(int n,int i){
return n&(1<<i);
}
bool cmp(const pair<int,int> &a,const pair<int,int>&b){
return a.second<b.second;
}
int main() {
int n;cin>>n;
int a[n];
for(int i=0;i<n;i++) cin>>a[i];
vector<pair<int,int>> v;
for(int i=0;i<n;i++){
int c=0;
for(int j=0;j<31;j++){
if(checkbit(a[i],j)) c++;
}
v.push_back({a[i],c});
}
int idx = 0;
sort(v.begin(),v.end(),cmp);
for(auto it : v){
a[idx++] = it.first;
cout<<it.second<<" ";
}
for(int i=0;i<n;i++){
cout<<a[i]<<" ";
}
return 0;
}
C++
Telegram:- @allcoding1
using namespace std;
bool checkbit(int n,int i){
return n&(1<<i);
}
bool cmp(const pair<int,int> &a,const pair<int,int>&b){
return a.second<b.second;
}
int main() {
int n;cin>>n;
int a[n];
for(int i=0;i<n;i++) cin>>a[i];
vector<pair<int,int>> v;
for(int i=0;i<n;i++){
int c=0;
for(int j=0;j<31;j++){
if(checkbit(a[i],j)) c++;
}
v.push_back({a[i],c});
}
int idx = 0;
sort(v.begin(),v.end(),cmp);
for(auto it : v){
a[idx++] = it.first;
cout<<it.second<<" ";
}
for(int i=0;i<n;i++){
cout<<a[i]<<" ";
}
return 0;
}
C++
Telegram:- @allcoding1
👍6❤1
def minimumCost(price):
n = len(price)
price.append(0)
ans = float('inf')
last = {price[0]: 0}
for i in range(1, n):
v = price[i]
price[i] += price[i - 1]
if last.get(v) != None:
ans = min(ans, price[i] - price[last[v]] + v)
last[v] = i
return ans if ans != float('inf') else -1
n = int(input())
price = list(map(int,input().split(' ')))
print(minimumCost(price))
Python 3
Amazon
Telegram:- @allcoding1
n = len(price)
price.append(0)
ans = float('inf')
last = {price[0]: 0}
for i in range(1, n):
v = price[i]
price[i] += price[i - 1]
if last.get(v) != None:
ans = min(ans, price[i] - price[last[v]] + v)
last[v] = i
return ans if ans != float('inf') else -1
n = int(input())
price = list(map(int,input().split(' ')))
print(minimumCost(price))
Python 3
Amazon
Telegram:- @allcoding1
👍11
string getLongestRegex(string a, string b, string c)
{
const size_t n = a.size();
int idx = -1;
for (int i = 0; i < n; i++) {
if (c[i] != a[i] && c[i] != b[i]) { idx = i; }
}
if (idx == -1) return "-1";
string res;
for (int i = 0; i < n; i++) {
if (i == idx) {
string cur = "[";
for (int j = 'A'; j <= 'Z'; j++) if (j != c[i]) cur += j;
cur += "]";
res += cur;
} else {
res += "[ABCDEFGHIJKLMNOPQRSTUVWXYZ]";
}
}
return res;
}
C++
Amazon
Telegram:- @allcoding1
{
const size_t n = a.size();
int idx = -1;
for (int i = 0; i < n; i++) {
if (c[i] != a[i] && c[i] != b[i]) { idx = i; }
}
if (idx == -1) return "-1";
string res;
for (int i = 0; i < n; i++) {
if (i == idx) {
string cur = "[";
for (int j = 'A'; j <= 'Z'; j++) if (j != c[i]) cur += j;
cur += "]";
res += cur;
} else {
res += "[ABCDEFGHIJKLMNOPQRSTUVWXYZ]";
}
}
return res;
}
C++
Amazon
Telegram:- @allcoding1
👍13❤1
🎯Infosys Hiring Power Programmer
Batch - 2022 and below Batch
Skills Set - Java Full Stack
Apply Now:- career.infosys.com/jobdesc?sourceId=4003&jobReferenceCode=INFSYS-EXTERNAL-160368
Telegram:- @allcoding1
Batch - 2022 and below Batch
Skills Set - Java Full Stack
Apply Now:- career.infosys.com/jobdesc?sourceId=4003&jobReferenceCode=INFSYS-EXTERNAL-160368
Telegram:- @allcoding1
👍2
🎯Amazon Hiring SME
Batch - 2021/2022/2023
Degree - BE, BSC, MCA, Msc
Apply now:- amazon.jobs/en/jobs/2442412/subject-matter-expert
Telegram:- @allcoding1
Batch - 2021/2022/2023
Degree - BE, BSC, MCA, Msc
Apply now:- amazon.jobs/en/jobs/2442412/subject-matter-expert
Telegram:- @allcoding1
👍3❤2👏1
🎯Optum Walk-in Drive 2023 For Chat Support
Location: Hyderabad
Qualification: Any Graduate
Work Experience: 0 – 1 years
Walk-In Date: 20th October 2023
Apply now:-
https://www.naukri.com/job-listings-walk-in-for-freshers-chat-support-united-health-group-optum-hyderabad-secunderabad-telangana-0-to-1-years-300623004099?source=jobscoupe.com
Telegram:- @allcoding1
Location: Hyderabad
Qualification: Any Graduate
Work Experience: 0 – 1 years
Walk-In Date: 20th October 2023
Apply now:-
https://www.naukri.com/job-listings-walk-in-for-freshers-chat-support-united-health-group-optum-hyderabad-secunderabad-telangana-0-to-1-years-300623004099?source=jobscoupe.com
Telegram:- @allcoding1
👍9
🎯Tech Mahindra Recruitment 2023 For Customer Service Associate
Location: Bangalore
Qualification: Undergraduate / Graduate / Post Graduate
Work Experience: Freshers / Experience
Apply now:-
https://www.naukri.com/job-listings-tech-mahindra-is-hiring-csa-international-voice-process-bengaluru-tech-mahindra-bangalore-bengaluru-0-to-4-years-091023002447?source=jobscoupe.com
Telegram:- @allcoding1
Location: Bangalore
Qualification: Undergraduate / Graduate / Post Graduate
Work Experience: Freshers / Experience
Apply now:-
https://www.naukri.com/job-listings-tech-mahindra-is-hiring-csa-international-voice-process-bengaluru-tech-mahindra-bangalore-bengaluru-0-to-4-years-091023002447?source=jobscoupe.com
Telegram:- @allcoding1
👍3
🎯DHL Off Campus Hiring For Software Engineer | Chennai | 4.5 LPA
Job Role : Software Engineer
Education : BE/BTech/MCA/MTech
Job Location : Chennai
Package : 4.5 LPA
Apply Now:- www.allcoding1.com
Telegram:- @allcoding1
Job Role : Software Engineer
Education : BE/BTech/MCA/MTech
Job Location : Chennai
Package : 4.5 LPA
Apply Now:- www.allcoding1.com
Telegram:- @allcoding1
👍3
🎯Hitachi GlobalLogic Hiring Analyst | Freshers to 2 Years | Any Graduate | 4 LPA
Job Role:-Associate Analyst
Qualification:-Any Graduate
Location:-Chennai
Salary/CTC:-5 LPA
Apply Now:- www.allcoding1.com
Telegram:- @allcoding1
Job Role:-Associate Analyst
Qualification:-Any Graduate
Location:-Chennai
Salary/CTC:-5 LPA
Apply Now:- www.allcoding1.com
Telegram:- @allcoding1
👍9
👍3
🎯Hitachi GlobalLogic Hiring Analyst | Freshers to 2 Years | Any Graduate | 4 LPA
Job Role:-Associate Analyst
Qualification:-Any Graduate
Location:-Chennai
Salary/CTC:-5 LPA
Apply Now:- www.allcoding1.com
Telegram:- @allcoding1
Job Role:-Associate Analyst
Qualification:-Any Graduate
Location:-Chennai
Salary/CTC:-5 LPA
Apply Now:- www.allcoding1.com
Telegram:- @allcoding1
👍1👏1
🎯BYJU’s Off Campus Drive 2023 for BDE | Any Graduate | Across India
Job Role : Business Development Associate
Qualification : Any Graduate
Experience : Freshers
Salary : Rs 12,000 to Rs 20,000/Month
Apply Now:- www.allcoding1.com
Telegram:- @allcoding1_official
Job Role : Business Development Associate
Qualification : Any Graduate
Experience : Freshers
Salary : Rs 12,000 to Rs 20,000/Month
Apply Now:- www.allcoding1.com
Telegram:- @allcoding1_official
👍4
🎯Deloitte Biggest Hiring | Open Talent Newtwork | Analyst Trainee | Salary:- 4 LPA
Job Role:- Analyst-Trainee
Qualification:- B.E./B.Tech
Salary:- 4 LPA
Apply Now:- www.allcoding1.com
Telegram:- @allcoding1
Job Role:- Analyst-Trainee
Qualification:- B.E./B.Tech
Salary:- 4 LPA
Apply Now:- www.allcoding1.com
Telegram:- @allcoding1
👍4