MINIMUM ADD TO MAKE PARENTHESIS VALID | PYTHON | LEETCODE # 921
Vložit
- čas přidán 6. 03. 2022
- In this video we are solving a popular Facebook interview question: Minimum Add to Make Valid Parenthesis. It's another one of these parenthesis questions that follows a similar pattern of needing to keep track of the l_count and r_count within the string and doing some processing based on the current status of the counts.
- Věda a technologie
This channel is extremely helpful for understanding how to approach LC medium to hard lvl problems. Thanks and I hope you continue to upload these helpful videos.
this can also be done more cleanly IMO using a stack, but it would use O(n) space complexity vs this one that uses O(1)
Hey could you please link the video of the minimum remove parentheses? I couldn't find it on your channel
I’m on mobile and can’t link but in case you haven’t found it yet search for “facebooks #1 interview question” on my channel and you should find it. I think I named it “min. remove” instead of “minimum remove” to save space in the title
great explanation!!
Glad you liked it!
Why not just reduce the lcount, if it is greater than 0 when we encounter right parentheses?
🎯 Key Takeaways for quick navigation:
Greedy left tracking
Balanced parentheses count
Iterative string processing
Made with HARPA AI