Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

95:: cath it

int minimumJumps(int x, int y) {


// Write your code here.
int temp=__gcd(x,y);
if(temp)
return (x/temp+y/temp);
return 0;
}

92-> Day 27: PAK vs BAN: Bait and switch::

long long baitAndSwitch(int n, vector<int> &a, int k, int m) {


// Write your code here.
priority_queue<int, vector<int>, greater<int>>pq;
for(int i=0;i<n;i++){
pq.push(abs(a[i]-m));
if(pq.size()>k)
pq.pop();
}
long long ans=0;
while (!pq.empty()) {
ans += pq.top();
pq.pop();
}
return ans;
}

91:: Day 27: PAK vs BAN: Bowler's Plan


char kthUnique(int n, string &s, int k) {
// Write your code here.
int arr[26]={0};
for(int i=0;i<n;i++){
if(!arr[s[i]-'a']){
if(k==1)
return s[i];
k--;
arr[s[i]-'a']=1;
}
}
return '?';
}

83:: Day 24: NED vs BAN: Distinct String


#include <bits/stdc++.h>
int simpleString(string s){

// Write your code here


int count=0;
for(int i=1;i<s.length();i++){
if(s[i]==s[i-1]){
count++;
if(i<s.length()-1)
s[i]=s[i]+1;
}
}
return count;
}

You might also like