czzonet / leetcode-crasher

leetcode-crasher || leetcode自己解题历程 每天一题
Apache License 2.0
0 stars 0 forks source link

20. Valid Parentheses #41

Closed czzonet closed 4 years ago

czzonet commented 4 years ago

20. Valid Parentheses

Easy

5518

233

Add to List

Share

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

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.

Example 1:

Input: s = "()"
Output: true

Example 2:

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

Example 3:

Input: s = "(]"
Output: false

Example 4:

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

Example 5:

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

Constraints:

Accepted

1,094,484

Submissions

2,799,753

czzonet commented 4 years ago

Done

Snipaste_2020-09-06_14-54-48