Problem · String
Is Balanced String
Learn this problemProblem statement
Write a function to check if the given input string is balanced or not. The input string will contain parentheses 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.
pps: 1 == true, 0 == false
Function
isBalancedString(s: String) → intExamples
Example 1
s = "(()1(1)) "return = 1:}
Example 2
s = ")1()"return = 1o.o
Example 3
s = ")(1))"return = 0:3
More Google problems
- Deduplicate Logs: Keep FirstONSITE INTERVIEW · Seen Jul 2026
- Deduplicate Logs: Keep LatestONSITE INTERVIEW · Seen Jul 2026
- Find a Template Across Binary-Tree LeavesONSITE INTERVIEW · Seen Jul 2026
- Maximum Programmer-Problem MatchingONSITE INTERVIEW · Seen Jul 2026
- Minimum Direction ViolationsONSITE INTERVIEW · Seen Jul 2026
- Stream Latest Log VersionsONSITE INTERVIEW · Seen Jul 2026
- Stream Unique Logs in Timestamp OrderONSITE INTERVIEW · Seen Jul 2026
- Top-K IP Addresses from File RecordsONSITE INTERVIEW · Seen Jul 2026