Определите, сбалансирована ли сгенерированная строка скобок; то есть, состоит ли он целиком из пар открывающих / закрывающих скобок (в этом порядке), ни одно из которых не выполняется.
Примеры:(пусто) true
[]
true
][
false
[][]
true
][][
false
[]][[]
false
[[[[]]]]
true
isBalanced
is a function.
testString: assert(typeof isBalanced === 'function');
- text: isBalanced("[]")
should return true.
testString: assert(isBalanced(testCases[0]));
- text: isBalanced("]][[[][][][]][")
should return false.
testString: assert(!isBalanced(testCases[1]));
- text: isBalanced("[][[[[][][[[]]]]]]")
should return true.
testString: assert(isBalanced(testCases[2]));
- text: isBalanced("][")
should return true.
testString: assert(!isBalanced(testCases[3]));
- text: isBalanced("[[[]]]][[]")
should return true.
testString: assert(!isBalanced(testCases[4]));
- text: isBalanced("][[]")
should return true.
testString: assert(!isBalanced(testCases[5]));
- text: isBalanced("][[][]][[[]]")
should return true.
testString: assert(!isBalanced(testCases[6]));
- text: isBalanced("[[][]]][")
should return true.
testString: assert(!isBalanced(testCases[7]));
- text: isBalanced("[[[]]][[]]]][][[")
should return true.
testString: assert(!isBalanced(testCases[8]));
- text: isBalanced("[]][[]]][[[[][]]")
should return true.
testString: assert(!isBalanced(testCases[9]));
- text: isBalanced("][]][[][")
should return true.
testString: assert(!isBalanced(testCases[10]));
- text: isBalanced("[[]][[][]]")
should return true.
testString: assert(isBalanced(testCases[11]));
- text: isBalanced("[[]]")
should return true.
testString: assert(isBalanced(testCases[12]));
- text: isBalanced("]][]][[]][[[")
should return true.
testString: assert(!isBalanced(testCases[13]));
- text: isBalanced("][]][][[")
should return true.
testString: assert(!isBalanced(testCases[14]));
- text: isBalanced("][][")
should return true.
testString: assert(!isBalanced(testCases[15]));
- text: isBalanced("[[]]][][][[]][")
should return true.
testString: assert(!isBalanced(testCases[16]));
- text: isBalanced("")
should return true.
testString: assert(isBalanced(testCases[17]));
```