Solution Review: Find Duplicate Parenthesis
This review provides a detailed analysis of finding duplicate parentheses.
We'll cover the following
Solution
The algorithm
works by adding all the elements except )
to the stack. When we get a )
at that point, we find its
corresponding pair and count all the elements between this pair. If the number of elements is 0 or 1, then
we have a redundant parenthesis.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.