📚 PracticeEasyAlgorithm ProblemCoding Ready

Valid Parentheses

stackstring
LeetCode #20
Updated Dec 20, 2025

Question

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

LeetCode: Valid Parentheses

An input string is valid if:

  1. Open brackets must be closed by the same type of brackets
  2. Open brackets must be closed in the correct order
  3. Every close bracket has a corresponding open bracket of the same type

Example:

Input: s = "()"
Output: true

Input: s = "()[]{}"
Output: true

Input: s = "(]"
Output: false

Input: s = "([)]"
Output: false

Input: s = "{[]}"
Output: true

Your Solution

python
Auto-saves every 30s

Try solving the problem first before viewing the solution


0:00time spent