It's a somewhat complex question, but your explanation makes it remarkably simple. Hats off to you!🤝
I was able to solve this question in 38 minutes. For the first 10 minutes, I couldn’t figure out how to approach it. Then I took a pen and paper and, slowly but steadily arrived at the solution using two stacks. Now I'm here to see you have implemented a different solution.
I think what makes this question tricky is that there can be multiple ways to approach it. When we start with an approach that seems to be working, even if it's actually wrong, we tend to stick with it and don’t explore other ideas. For example, I initially thought of this approach: First, I tried to find the smallest character in the string. Then, I pushed all characters till index i into a stack. After that, I used a pointer starting from i+1 to the end of the string. While traversing, I kept comparing the character at the pointer with the top of the stack, and added the smaller one to the result. Depending on the comparison, I either popped the stack or moved the pointer ahead. But this approach failed when there were multiple smallest characters in the string. To fix this, I then tried computing the result for each occurrence of the smallest character. Even with that improvement, the solution still didn't work, and I realized my logic had flaws.
WOOWW..... you made this super easy, I was trying on my own like this only but couldn't get to the solution and you helped just perfectly.!
sir please make a video on dp with bit masking
you have consistency of 831 days man wao..
awesome, keep going 🤩. I was thinking DP and taking all combinations and selecting setting the smallest out of them. but your solution is genius
can you please share your journey? By looking at your explanation, it feels something connected, it would be very inspiring if possible.
Progress day 1: Tried this problem for 2+ hours Solution mistake : I didn't consider the case where two chars will be same , Stored the index of char jn a map And traversed the map and took a stack This solution will work only for unique char string Then came up with the solution using minimumsuffix array But unfortunately didn't able to solve the solution something went wrong Thanks MIK Great learning
VERY BIG FAN! Have watched your complete graphs,DP & Trees playlist. This problem now feels like a cakework. It would be great if you could also tell me some similar questions related to it.
leetcode editorial me bahot bakwaas likha hota hai. thanks a lot for simplifying the problem. easily solved after pausing the video at the moment when you told we need to check smaller in the right
Your solution is simpler and clear than leetcode editorial. thanks a lot
pretty clean... loved it!!
Amazing and extremely simplified
thanks brother 👍👍👍
made very easy. thanks man
dude could u please post a vid on 282 leetcode???(its def a humble req) people are directly using 3-4 changing parameters in backtracking without telling why !! anyways i would suggest u to solve all 1-500 questions from leetcode and put them in a playlist .. as far as ik those questions are asked by many companies and they are def popular .. so u will def get more reach -- just an advice ..
I was able to catch this that we need to find smallest char to right, but apne aap par bharosa nhi ho rha tha 🥺
just here to understand the problem properly ,krunga to khud
@swatiprakrutidas1818