Tech IndustryOct 26, 2018
Chaseghosted!

Interview tip: Always have an iterative version ready !

Furiously writing down a 5 line recursive solution in 2 mins is a near certain invitation to rewrite it iteratively(" that's great, but what's the risk of recursion? Oh so you know about stack space overflow, well can you try it without recursion?"). And it's not always trivial to convert it on the spot without prior preparation. Simplest example: post order traversal of binary tree.

Google tc?..$FU Oct 26, 2018

Also don’t solv any problem in 2 mins. Take some acting lessons.

Facebook polyp Oct 26, 2018

Disagree, just blow through as many as you can. Leave the interviewer stunned.

Microsoft onestunt Oct 26, 2018

Bad advise. Interviewers are insecure people, they want to feel important about the question they asked

Amazon bHXi80 Oct 26, 2018

From my experience if you solve the problem in 2 mins there will be follow up questions that will blow the interviewee

Microsoft Tronkator Oct 26, 2018

It is actually very straightforward to convert into an iterative solution. And for the most part, a case that does stack overflow recursively but works fine iteratively is really hard to find IRL

Amazon ♋️ Oct 27, 2018

The iterative solution is valuable if all it does is make explicit how much is stored on the stack at each level, but I agree to a point, if there is a mechanism that will do your housekeeping for you why do it yourself. OTOH, if you notice that your recursive solution uses only tail calls, and the language that you are answering in doesn’t support tail call optimizations, then pointing this out and converting to a loop is probably a good thing

Conduent sAhI83 Oct 27, 2018

If I suck at recursion should I just never use it then?

Facebook useState Oct 28, 2018

Yes. For my Google interview I solved too fast and the follow up was a tweak to the question that required DP to solve efficiently wtf