791. Custom Sort String | 2 Approaches | Custom Comparator | Hash Map | Meta

In this video, I'll talk about how to solve Leetcode 791. Custom Sort String | Custom Comparator | Hash Map | Meta
Checkout DSA-169 Series: • Aryan DSA-169 Series |...
100Days 100k Placements: • 100 Days 100K Placement
Let's Connect:
📝Linkedin: / aryan-mittal-0077
📸 Instagram: / ez.pz.dsa
📱Telegram : t.me/aryan_mittal_group
🤖 Github: github.com/aryan-0077
About Me:
I am Aryan Mittal - A Software Engineer in Goldman Sachs, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)
✨ Timelines✨
✨ Hashtags ✨
#programming #Interviews #leetcode #faang #maang #datastructures #algorithms

Пікірлер: 21

  • @ARYANMITTAL
    @ARYANMITTAL4 ай бұрын

    I guess Leetcode Easy days are gone, this week is gonna be Medium & next Hard 🫡🧑🏻‍🦯

  • @kabir2190

    @kabir2190

    4 ай бұрын

    today's question was also easy but i was stucked in one of the syntax😅

  • @Engineering.Wallah

    @Engineering.Wallah

    4 ай бұрын

    class Solution { public: string customSortString(string order, string s) { vectorfreq1(26,0); vectorfreq2(26,0); for(char c:order) freq1[c-'a']++; for(char c:s) freq2[c-'a']++; string ans; for(int i=0;i

  • @Engineering.Wallah

    @Engineering.Wallah

    4 ай бұрын

    class Solution { public: string customSortString(string order, string s) { vectorfreq1(26,0); vectorfreq2(26,0); for(char c:order) freq1[c-'a']++; for(char c:s) freq2[c-'a']++; string ans; for(int i=0;i

  • @kabir2190

    @kabir2190

    4 ай бұрын

    class Solution { public: string customSortString(string order, string s) { unordered_mapmack; for(auto it : s){ mack[it]++; } for(int i = 0 ; isecond , it->first); } return storage; } };

  • @saibhaskar6939

    @saibhaskar6939

    4 ай бұрын

    Excellent explanation bhaiii 🫡💫

  • @darth_vader_11
    @darth_vader_114 ай бұрын

    bro used C++17 all of a sudden, I didnt even knew that structured binding part you used in the second for loop for collecting remaining elements. For those who didnt knew, here is what I understood: for(auto [el, fr] : freq) is an example of "structured binding" introduced in C++17 that allows you to decompose a tuple-like object (such as a pair) into its individual components. So that In each iteration, the loop extracts a key-value pair (character-frequency pair) from the freq map. el represents the key (character), and fr represents the value (frequency) corresponding to that key in the map.

  • @darshan3297

    @darshan3297

    4 ай бұрын

    Thanks for letting us know

  • @ARYANMITTAL

    @ARYANMITTAL

    4 ай бұрын

    Nice explanation Ankandas 🙇🫡❤️

  • @coderunner743
    @coderunner7434 ай бұрын

    thanks for teaching some C++ stuff

  • @AnshuHarshit
    @AnshuHarshit4 ай бұрын

    Bro provide code link also cuz I do dsa using java. So sometimes it's helpful to understand the code more clearly in java.

  • @dhruvrawatt9
    @dhruvrawatt94 ай бұрын

    Aryan sir please u mentioned if the order of rest elements need to be same then what changes have to be made ?

  • @vigneshs1852
    @vigneshs18524 ай бұрын

    i used hashmap brother...thank you

  • @paulodim5703
    @paulodim57034 ай бұрын

    Really good video bro! I have a question tho, why does the second algorithm has a O(1) space complexity? If you created a new string called ans, shouldn't it be O(n) ?

  • @learningmaths786

    @learningmaths786

    4 ай бұрын

    ans is a one which mandatory for returning so constant 1

  • @dhruvrawatt9

    @dhruvrawatt9

    4 ай бұрын

    string ,int,char,long long are jjust variables ,they are not considered as auxiliary space

  • @mukulkhanna5071
    @mukulkhanna50714 ай бұрын

    bhai opening line bdia to bhot lagi par chai and code ki jaise lag rhi hai🤣🤣🤣🤣

  • @satwiktatikonda764
    @satwiktatikonda7644 ай бұрын

    Bro Rabin karp 😢

  • @dhruvrawatt9

    @dhruvrawatt9

    4 ай бұрын

    what hapened?

  • @Engineering.Wallah
    @Engineering.Wallah4 ай бұрын

    class Solution { public: string customSortString(string order, string s) { vectorfreq1(26,0); vectorfreq2(26,0); for(char c:order) freq1[c-'a']++; for(char c:s) freq2[c-'a']++; string ans; for(int i=0;i