Dodomeki
Sign in

15. Valid Parentheses

Easy

Given a string texto made up of the characters ()[]{}, determine whether the pairs are well formed. Each opening symbol must be closed by the same type of symbol, and the closing symbols must respect the nesting order.

Example 1
Input: texto = "{[()]}"
Output: true
Explanation: Each symbol closes its matching opening symbol in the correct order.
Example 2
Input: texto = "([)]"
Output: false
Explanation: The parenthesis closes before the bracket that was opened most recently.
Constraints
  • 0 <= texto.length <= 10^4
  • texto contains only `()[]{}`.
StringsStack
Caso 1
texto =
"{[()]}"
Expected =
true
Caso 2
texto =
"([)]"
Expected =
false

Run checks these 2 cases. Submit runs all 6, including hidden ones.