EasyTopic: StacksExpected: O(N) Time • O(N) Space

Valid Balanced Parentheses

Given a string `s` made up only of the bracket characters `(`, `)`, `{`, `}`, `[`, and `]`, determine whether the brackets in `s` are properly balanced. A string is balanced when: 1. Every opening bracket is eventually closed by a bracket of the same type. 2. Brackets close in the correct nested order. 3. Every closing bracket has a matching opening bracket earlier in the string.

Examples
Input: s = "{[()]}"
Output: true
Input: s = "{[}]"
Output: false
Input: s = "((()"
Output: false
Constraints
  • 0 <= s.length <= 2 * 10^4
  • s contains only the bracket characters ()[]{}
solution.js
JavaScript (ES6+)
Test Execution Results
Input:["{[()]}"]
Expected:true
Your Output:--