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.
From my experience if you solve the problem in 2 mins there will be follow up questions that will blow the interviewee
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
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
If I suck at recursion should I just never use it then?
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
Also don’t solv any problem in 2 mins. Take some acting lessons.
Disagree, just blow through as many as you can. Leave the interviewer stunned.
Bad advise. Interviewers are insecure people, they want to feel important about the question they asked