10 lines
200 B
Text
10 lines
200 B
Text
|
|
isBalanced = function(str)
|
||
|
|
level = 0
|
||
|
|
for c in str
|
||
|
|
if c == "[" then level = level + 1
|
||
|
|
if c == "]" then level = level - 1
|
||
|
|
if level < 0 then return false
|
||
|
|
end for
|
||
|
|
return level == 0
|
||
|
|
end function
|