๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
int minCostToReachDestination(int N, vector<int>& A) { vector<int> dp(N + 1, INT_MAX); dp[1] = 0; for (int i = 1; i <= N; i++) { if (i + 1 <= N) { dp[i + 1] = min(dp[i + 1], dp[i] + abs(A[i] - A[i - 1])); โฆ
All passed
Python 3โ
Amazon ML
Amazon ML
๐ข3
int countOccurrences(string parent, string sub) {
transform(parent.begin(), parent.end(), parent.begin(), ::tolower);
transform(sub.begin(), sub.end(), sub.begin(), ::tolower);
int count = 0;
size_t pos = parent.find(sub);
while (pos != string::npos) {
count++;
pos = parent.find(sub, pos + 1);
}
return count;
}
Citi bank โ
transform(parent.begin(), parent.end(), parent.begin(), ::tolower);
transform(sub.begin(), sub.end(), sub.begin(), ::tolower);
int count = 0;
size_t pos = parent.find(sub);
while (pos != string::npos) {
count++;
pos = parent.find(sub, pos + 1);
}
return count;
}
Citi bank โ
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Mondelez International is hiring through Hackathon
For 2022/2023 Grads
Apply fast :
https://tinyurl.com/umd42w4f
For 2022/2023 Grads
Apply fast :
https://tinyurl.com/umd42w4f
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
def gameWinner(colors):
currPlayer = "wendy"
prevPlayer = ""
winner = ""
while True:
moveMade = False
if currPlayer == "wendy":
whiteIndex = colors.find("www")
if whiteIndex = -1:
# 3 consecutive whites found, remove the middle one
colorsBuilder = list(colors)
colorsBuilder.pop(whiteIndex + 1)
colors = "".join(colorsBuilder)
moveMade = True
prevPlayer = currPlayer
currPlayer = "bob"
else:
blackIndex = colors.find("bbb")
if blackIndex != -1:
# 3 consecutive blacks found, remove the middle one
colorsBuilder = list(colors)
colorsBuilder.pop(blackIndex + 1)
colors = "".join(colorsBuilder)
moveMade = True
prevPlayer = currPlayer
currPlayer = "wendy"
# if no moves possible break
if not moveMade:
winner = prevPlayer
break
return winner
print(gameWinner("wwwbb"))
Python 3โ
Game Winner
JP Morgan
currPlayer = "wendy"
prevPlayer = ""
winner = ""
while True:
moveMade = False
if currPlayer == "wendy":
whiteIndex = colors.find("www")
if whiteIndex = -1:
# 3 consecutive whites found, remove the middle one
colorsBuilder = list(colors)
colorsBuilder.pop(whiteIndex + 1)
colors = "".join(colorsBuilder)
moveMade = True
prevPlayer = currPlayer
currPlayer = "bob"
else:
blackIndex = colors.find("bbb")
if blackIndex != -1:
# 3 consecutive blacks found, remove the middle one
colorsBuilder = list(colors)
colorsBuilder.pop(blackIndex + 1)
colors = "".join(colorsBuilder)
moveMade = True
prevPlayer = currPlayer
currPlayer = "wendy"
# if no moves possible break
if not moveMade:
winner = prevPlayer
break
return winner
print(gameWinner("wwwbb"))
Python 3โ
Game Winner
JP Morgan
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
def cardinalitySort(nums): return sorted(nums, key=lambda num: [bin(num).count('1'), num]) Cardinality sorting JP Morgan โ
#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() {
// your code goes here
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++โ
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() {
// your code goes here
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++โ
Pair Xor
C++โ
C++โ
XOR and Inversion
C++โ
C++โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
KPMG is hiring #freshers for the post of Full Stack Developer Analyst!
Experience - 0 to 3 Year's
Location - Pune
Salary Range - 5.5 to 13 LPA
Apply Now -
https://lnkd.in/dutPG9TV
Experience - 0 to 3 Year's
Location - Pune
Salary Range - 5.5 to 13 LPA
Apply Now -
https://lnkd.in/dutPG9TV
lnkd.in
LinkedIn
This link will take you to a page thatโs not on LinkedIn
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Tata 1mg
Role: SDE 1 - Frontend
Batch eligible: 2021, 2022 and 2023 grads
Apply: https://1mg.darwinbox.in/ms/candidate/careers/a64f836a03fe49
Role: SDE 1 - Frontend
Batch eligible: 2021, 2022 and 2023 grads
Apply: https://1mg.darwinbox.in/ms/candidate/careers/a64f836a03fe49
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Amazon is hiring for Data Scientist Interns!
Batch : 2023 / 2024 / 2025
Locations : Bangalore, Hyderabad, Chennai
Expected Salary: INR 20k - 25k/month (via Glassdoor)
Apply - https://lnkd.in/d57QbTUS
Batch : 2023 / 2024 / 2025
Locations : Bangalore, Hyderabad, Chennai
Expected Salary: INR 20k - 25k/month (via Glassdoor)
Apply - https://lnkd.in/d57QbTUS
Anyone give zscaler OA exam 11am
๐4