Summary
I interviewed for an L4 role at Google India and was asked a nested expression evaluation problem. I provided a working solution but missed an edge case, and ultimately received a rejection shortly after the phone screen.
Full Experience
I was asked the following question:
- Given an expression evaluate it's value:
Input: add(5,mul(2,pow(5,2)))
Output: 55
I asked some clarifying questions about the input and got:
- There can be 5 binary functions:
add,mul,div,sub,pow divis NOT integer division so need to return double- Input will have positive integers
- There can be spaces in the input
It's a simple question but implementation gets messier and messier once you start coding. I did a decent attempt at the problem and I was able to provide a working solution. I missed an edge case which the interviewer pointed out and after thinking for a few minutes I fixed it.
Within 5 minutes into the interview, I knew I'm not going to be selected. Because first, I immediately knew this implementation is going to be messy and second, the interviewer was not offering any feedback as I spoke.
In these type of tricky question where you can't formulate a perfect algorithm handling all cases, it's essential for your interviewer to understand and give feedback to your approach. Since he was not doing that I knew I will fail.
The recruiter called 30 minutes after the inteview and informed about the rejection. She said that everything was poor: DSA, implementation, and logic and asked me to try again after a year.
Interview Questions (1)
Given an expression string with nested binary functions (add, mul, div, sub, pow), evaluate its value. Clarifications included:
- There can be 5 binary functions:
add,mul,div,sub,pow divis NOT integer division so need to return double- Input will have positive integers
- There can be spaces in the input
Example:
Input: add(5,mul(2,pow(5,2)))
Output: 55