9 lines
230 B
Text
9 lines
230 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
|