I had programming interview which consisted of 3 interviewers, 45 min each. While first two interviewers gave me 2-3 short coding questions (i.e reverse linked list, implement rand(7) using rand(5) etc ) third interviewer used whole timeslot for single question:
You are given string representing correctly formed and parenthesized boolean expression consisting of characters T, F, &, |, !, (, ) an spaces. T stands for True, F for False, & for logical AND, | for logical OR, ! for negate. & has greater priority than |. Any of these chars is followed by a space in input string. I was to evaluate value of expression and print it (output should be T or F). Example: Input: ! ( T | F & F ) Output: F
I tried to implement variation of Shunting Yard algorithm to solve the problem (to turn input in postfix form, and then to evaluate postfix expression), but failed to code it properly in given timeframe, so I ended up explaining in pseudocode and words what I wanted.
My recruiter said that first two interviewers gave me "HIRE", while third interviewer gave me "NO HIRE", and since the final decision is "logical AND", he thanked me for my time.
My questions: Do you think that this question is appropriate to code on whiteboard in approx. 40 mins? To me it seems to much code for such a short timeslot and dimensions of whiteboard. Is there shorter approach than to use Shunting yard algorithm for this problem?