Custom Sort String | Leetcode 791 | Live coding session

preview_player
Показать описание
Here is the solution to "Custom Sort String" leetcode question. Hope you have a great time going through it.

Chapters
1) 0:00 Explaining the problem out loud
2) 1:10 Question walkthrough
3) 2:30 Algorithm
5) 6:00 Coding it up

For discussion/feedback

PS : Please increase the speed to 1.25X
Рекомендации по теме
Комментарии
Автор

One of the most underrated channel. I'm sure this channel will grow leaps and bounds. Thanks for making these videos, Sanchit !

rajeshseptember
Автор

Thank you so much for posting videos so consistently! They help a lot!

aayushit
Автор

I used the comprator function although nice approach

abhishekhorton
Автор

char * customSortString(char * order, char * str){

int i, j, c=1;
int temp[26];

for(i=0;i<26;i++)
temp[i]=0;

//For finding the frequency of all charecters
for(i=0;i<strlen(str);i++){
temp[str[i]%97]++;
}
//To print the frequency of charecters temp!=0 means= that particular charecter is not present in string
for(i=0;i<26;i++){
if(temp[i]!=0)
printf("%d : %ds ", i, temp[i]);
}

int index=0;

while(temp[order[i]%97]!=0){
str[index++]=order[i];
temp[order[i]%97]--;
}
}
for(i=0;i<26;i++){
while(temp[i]!=0){
str[index++]=i+97;
temp[i]--;
}
}

return str;
}

can i make this still more efficient?

abinesh
welcome to shbcf.ru