Challenge: Balanced Parentheses

Learn how to balance parentheses.

Problem statement

Write a program to check balanced symbols, such as {}, (), []. The closing symbol should be matched with the most recently seen opening symbol. For example, {()} is legal, {() ({})} is legal, but {((} and {(}) are not legal.

Get hands-on with 1400+ tech skills courses.