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.

Get hands-on with 1400+ tech skills courses.