Need help on this Google Virtual Onsite problem
Anonymous User
678

Had a virtual onsite (L4) with google last month. Overall it was not too difficult but I failed. Four coding rounds + one behavioral round.
Three problems I was able to solve but this problem I stucked and bombed the round.

The problem is given a string of expressions contains a single variable x and int value of x. Only following characters in the string: comparators ('<', '>', '=='), boolean operator string "AND, OR" , left and right parantehis "(" ")" .
Goal is to evaluate the expression with the given value, return true or false. Assume the general arithmetic precedence( paranthesis takes high priority, expression evaluated from left to right, only above operator appear)
ex: “(x > 3) AND (x < 6)” , x = 4 ⇒ return true
I think this problem is similar to basic calculator problems and attempted to use stack for iterative approach. But I soon got lost in all if/else if cases. Is anyone having inputs/suggested approach for this problem?

Comments (4)