Reorganize String (LeetCode 767) | Full solution with scenario breakdown for easy explanation

Actual problem on HackerRank: leetcode.com/problems/reorgan...
Chapters:
00:00 - Intro
00:39 - Problem statement and description
02:43 - Brute Force approach
04:42 - Efficient solution (Breaking down scenarios)
12:20 - Dry-run of Code
14:47 - Final Thoughts
📚 Links to topics I talk about in the video:
Majority Element: • Majority Element (Leet...
Problems on Strings: • Strings
Other Medium Difficulty Problems: • Medium Problems
📘 A text based explanation is available at: studyalgorithms.com
Code on Github: github.com/nikoo28/java-solut...
Test-cases on Github: github.com/nikoo28/java-solut...
📖 Reference Books:
Starting Learn to Code: amzn.to/36pU0JO
Favorite book to understand algorithms: amzn.to/39w3YLS
Favorite book for data structures: amzn.to/3oAVBTk
Get started for interview preparation: amzn.to/39ysbkJ
🔗 To see more videos like this, you can show your support on: www.buymeacoffee.com/studyalg...
🎥 My Recording Gear:
Recording Light: amzn.to/3pAqh8O
Microphone: amzn.to/2MCX7qU
Recording Camera: amzn.to/3alg9Ky
Tablet to sketch and draw: amzn.to/3pM6Bi4
Surface Pen: amzn.to/3pv6tTs
Laptop to edit videos: amzn.to/2LYpMqn
💻 Get Social 💻
Follow on Facebook at: / studyalgos
Follow on Twitter at: / studyalgorithms
Follow on Tumblr at: / studyalgos
Subscribe to RSS feeds: studyalgorithms.com/feed/
Join fan mail: eepurl.com/g9Dadv
#leetcode #programming #interview

Пікірлер: 30

  • @user-fc1hx8bj6u
    @user-fc1hx8bj6u4 ай бұрын

    This is your first video I watched, while watching I am commenting for your effort and quite clear explanation!📸

  • @tejuschaturvedi6234
    @tejuschaturvedi623411 ай бұрын

    Excellent Explanation Sir .

  • @pryansh_
    @pryansh_11 ай бұрын

    it really helped, thanks !

  • @nikethdonthula2123
    @nikethdonthula212311 ай бұрын

    Really !! Very Well Explained Sir ❤

  • @soumikpaul6503
    @soumikpaul65035 ай бұрын

    Excellent Explanation, Thanks a lot, sir.

  • @nikoo28

    @nikoo28

    5 ай бұрын

    Thanks and welcome

  • @Slow_learner33
    @Slow_learner33 Жыл бұрын

    Hello Nikhil sir , your way of teaching is amazing 👏 your content for visualization dsa or any question solution is unique. Thanks for providing such content from your busy schedule❤❤.

  • @nikoo28

    @nikoo28

    Жыл бұрын

    That is really nice of you. I will try my best to keep bringing quality content. Stay tuned for more videos :)

  • @techstar3850
    @techstar38507 ай бұрын

    Excellent Explanation Sir, Thank you so much for the content. We need a creator like you.

  • @nikoo28

    @nikoo28

    7 ай бұрын

    Glad you feel that way.

  • @helsinkired8523

    @helsinkired8523

    3 ай бұрын

    @@nikoo28 in the last for loop you are not picking up the next highest frequency element to fill the remaining spaces.

  • @helsinkired8523

    @helsinkired8523

    3 ай бұрын

    can you please elaborate on this

  • @priyanshgarg1292
    @priyanshgarg1292 Жыл бұрын

    tnks

  • @pratikbhalerao6188
    @pratikbhalerao618811 ай бұрын

    Wow such a beautiful explanation ❤️

  • @nikoo28

    @nikoo28

    10 ай бұрын

    Thanks a lot 😊

  • @ShivamGupta-po7rg
    @ShivamGupta-po7rg11 ай бұрын

    best explanation

  • @helsinkired8523
    @helsinkired85233 ай бұрын

    Filling the remaining characters by next higher frequency is not mandatory requirement (you can see in the code as well). You can fill it in any way possible. It's because we are filling in alternate positions and two same characters will not be filled side by side.

  • @shubhamgupta8248
    @shubhamgupta824811 ай бұрын

    The while loop working is not clear syntactically,, does it mean the same as while(hash(letter)!=0)

  • @startercoder

    @startercoder

    11 ай бұрын

    yes! hash[letter]!=0

  • @surajsidar3280
    @surajsidar328012 күн бұрын

    hash[letter] -- >0 was confusing for me. I thought it might be some new operator introduced in Java. Later I searched on Meta AI and found that hash[letter]-- is a decrement operator

  • @EgorChebotarev
    @EgorChebotarev2 ай бұрын

    nice

  • @ThanosisContemplating
    @ThanosisContemplating11 ай бұрын

    while filling the remaining chars why are we not taking in account the decreasing order of the frequency of majority elements.

  • @KajalKumari-wy6ml

    @KajalKumari-wy6ml

    11 ай бұрын

    we are doing that in the while loop only. while(hash[I]-- > 0)

  • @helsinkired8523

    @helsinkired8523

    3 ай бұрын

    @@KajalKumari-wy6ml How so? the while loop just checks if the frequency is zero and continue to next iteration of for loop. Can you please explain how the while loop picking up the next high frequency element?

  • @pranavmahajan4190
    @pranavmahajan41905 ай бұрын

    I tried similar logic but it does not work if the string is like "aaabbbcc" it puts a b a b a b c c

  • @ShivaShankar-zc1ih

    @ShivaShankar-zc1ih

    5 ай бұрын

    Ur approach is wrong bro

  • @pranavmahajan4190

    @pranavmahajan4190

    5 ай бұрын

    @@ShivaShankar-zc1ih - how come approach is wrong?

  • @nikoo28

    @nikoo28

    5 ай бұрын

    what is your logic? give me a pseudo code

  • @NITian_BSam
    @NITian_BSamАй бұрын

    all the test cases are not passing

  • @nikoo28

    @nikoo28

    23 күн бұрын

    can you tell which one fails?

Келесі