This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Problem for week 1 codebuddy web club: https://www.interviewbit.com/problems/max-distance/ | |
int Solution::maximumGap(const vector<int> &A) { | |
vector<pair<int,int>>v; | |
int n = A.size(); | |
for(int i=0;i<n;i++){ | |
v.push_back(make_pair(A[i],i)); | |
} | |
sort(v.begin(),v.end()); | |
int largest, max_diff; | |
largest = v[n-1].second; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Problem for week 1 codebuddy IEEE: https://www.interviewbit.com/problems/largest-number/ | |
bool comp(string a, string b){ | |
string f1 = a+b; | |
string f2 = b+a; | |
return f1>f2?1:0; | |
} | |
string Solution::largestNumber(const vector<int> &A) { | |
if(!accumulate(A.begin(),A.end(),0)) | |
return "0"; |