I wrote an in-depth look at the Valid Parenthesis Problem (LeetCode 0020) with four separate solutions. Starting with a full breakdown of the description, building out a basic solution, and then iterating toward three more concise solutions. I hope you find it interesting, useful, or both! https://lnkd.in/gW6ahjyv #Coding #LeetCode #CodingProblems #LeetCodeSolutions
I thought I just solved this with one line of regex: \((?:[^()]*|(?R))*\) ...then realized I forgot about the other bracket types... and the nesting... and then I realized this one line of regex is wrong AND not useful 😂
Senior Software Engineer @ VMO
1wI remember doing this one. On my second attempt I ended up choosing the fourth option. I find that most of these challenges eventually come down to using while loops, sliding windows, and maps or sets to keep the time complexity efficient.