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
This is your first video I watched, while watching I am commenting for your effort and quite clear explanation!📸
Excellent Explanation Sir .
it really helped, thanks !
Really !! Very Well Explained Sir ❤
Excellent Explanation, Thanks a lot, sir.
@nikoo28
5 ай бұрын
Thanks and welcome
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
Жыл бұрын
That is really nice of you. I will try my best to keep bringing quality content. Stay tuned for more videos :)
Excellent Explanation Sir, Thank you so much for the content. We need a creator like you.
@nikoo28
7 ай бұрын
Glad you feel that way.
@helsinkired8523
3 ай бұрын
@@nikoo28 in the last for loop you are not picking up the next highest frequency element to fill the remaining spaces.
@helsinkired8523
3 ай бұрын
can you please elaborate on this
tnks
Wow such a beautiful explanation ❤️
@nikoo28
10 ай бұрын
Thanks a lot 😊
best explanation
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.
The while loop working is not clear syntactically,, does it mean the same as while(hash(letter)!=0)
@startercoder
11 ай бұрын
yes! hash[letter]!=0
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
nice
while filling the remaining chars why are we not taking in account the decreasing order of the frequency of majority elements.
@KajalKumari-wy6ml
11 ай бұрын
we are doing that in the while loop only. while(hash[I]-- > 0)
@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?
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
5 ай бұрын
Ur approach is wrong bro
@pranavmahajan4190
5 ай бұрын
@@ShivaShankar-zc1ih - how come approach is wrong?
@nikoo28
5 ай бұрын
what is your logic? give me a pseudo code
all the test cases are not passing
@nikoo28
23 күн бұрын
can you tell which one fails?