Is Balanced String
Updated
Problem 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 Phone Screen questions
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
- Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
- Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Logger Rate Limiter with Every-Arrival HistoryPHONE SCREEN · Seen Nov 2026
Similar questions at other companies
- Adjacent Pair and Run RemovalWhatNot · PHONE SCREENWhatNot interview questions
- Remove Parentheses from a Plus-Minus ExpressionOracle · PHONE SCREENOracle interview questions
- Parse a Partial JSON StreamListen Labs · PHONE SCREEN
- Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREENRoblox interview questions
- Decode StringCompass International Holdings · PHONE SCREENCompass International Holdings interview questions
- Remove K DigitsProcol · PHONE SCREEN
- Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
- Inverse-Depth Nested List SumLinkedIn · PHONE SCREENLinkedIn interview questions
- Multiline Text Editor with Cursor MovementDatologyAI · PHONE SCREEN
- Run a Stack Language InterpreterJane Street · PHONE SCREENJane Street interview questions