#4

Valid Parentheses

Easy
All Problems

4. Valid Parentheses#20

Easy📚 StackStack Matching

Determine if a string of brackets is valid — every open bracket must have a matching close bracket in the correct order.

Examples

Example 1:
Input: ["()"]
Output: true
Example 2:
Input: ["()[]{}"]
Output: true
Example 3:
Input: ["(]"]
Output: false

Why learn this

THE classic introduction to the stack data structure. Appears on every beginner list.

StacksString Parsing
Python 3Loading Python engine...
Click "Run Code" to test your solution