Google Phone screen
Anonymous User
2306

write a function to check given input string is balanced or not.
input string will contain paranthesis and digits.

whenever digit is occurred you need to remove digit number left side paranathesis in any order (ex: if digit is 2 you need to remove 2 paranthesis from left side means if inp == )(1, either I can remove ( or ) left side of 1). string is balanced if opening paranthesis is equal to closing (ex: (()), ()(), ()), treat each digit seperately if 11 is present in input treat them as 2 ones.

ex:

inp = (()1(1)) --> True
inp = )1() --> True
inp = )(1)) --> False

Comments (16)