Meta Interview Question

A function to find if a string has matching parenthesis or not

Interview Answer

Anonymous

Jul 28, 2018

Use a stack! Push when finding an opening parenthesis, when you find a closing one, pop an element if there is one, if there isn't, return false. After you are finish processing every element, if the stack is not empty, return false, else return true.