Given a string str
consisting of characters such as '(', ')', '{', '}', '[' and ']'
, determine if the input string is properly balanced.
A string is considered balanced if:
(
with )
, {
with }
, and [
with ]
)([])
is valid, but ([)]
is not){[(])}
is not balanced because the contents inside {
and }
are unbalanced).str: string
: A stringInput: str = "[]"Output: trueExplanation: The string contains correctly paired and ordered parentheses.
Input: str = "([)]"Output: falseExplanation: The string contains correctly paired but incorrectly ordered parentheses.
Input: str = "([]){}"Output: trueExplanation: The string contains correctly paired and ordered parentheses.
strs.length
<= 1000str
contains only the characters (
, )
, {
, }
, [
and ]
Given a string str
consisting of characters such as '(', ')', '{', '}', '[' and ']'
, determine if the input string is properly balanced.
A string is considered balanced if:
(
with )
, {
with }
, and [
with ]
)([])
is valid, but ([)]
is not){[(])}
is not balanced because the contents inside {
and }
are unbalanced).str: string
: A stringInput: str = "[]"Output: trueExplanation: The string contains correctly paired and ordered parentheses.
Input: str = "([)]"Output: falseExplanation: The string contains correctly paired but incorrectly ordered parentheses.
Input: str = "([]){}"Output: trueExplanation: The string contains correctly paired and ordered parentheses.
strs.length
<= 1000str
contains only the characters (
, )
, {
, }
, [
and ]
console.log()
statements will appear here.