I found your channel through recommendations. I applaud your effort in visualizing the entire logic. Perhaps might dive into LeetCode someday for the fun of it!
@CodeWithZiАй бұрын
I am glad you liked it! its def a cool ride highly recommend diving into it!
@PaintHimАй бұрын
I'm new to DSA and to leetcode, but would this be a good problem for a heap? create 5 nodes, one for each unique letter, and loop through the string. Each time you get b, a, or n, increment the respective node by 2, and each time you get l or o, increment by one. That way, when you look at the top node in the minimum heap, that letter will have the minimum number of repetitions and will decide how many times you can form "balloon" (and that's why letters b, a, and n would get incremented by 2)
@CodeWithZiАй бұрын
Your heap approach is quite inventive! However, it might be a bit more complex than needed for this problem. A more efficient solution would be to simply count the occurrences of the letters ‘b’, ‘a’, ‘l’, ‘o’, and ‘n’. Then, you can easily determine how many times you can form the word “balloon” based on their required quantities. This way, the solution remains clean and straightforward! Thanks for sharing your creative approach!
@talhazaryabАй бұрын
@PaintHim Can you please share the code snippet ? I can understand your explanation but maybe your code can help. I am very curious