Stacks: Check if opening parenthesis pattern matches closing parenthesis
pattern.