Member-only story
My Interviewer Asked Me About Fibonacci, but He Didn’t Like My Answer
Bro, Forget this team and interview another one.
The Story
X: “Hey, I want to tell you about a question I got in my interview. It was the third round, and as a warm-up question, the ‘bar raiser’ asked me to solve Fibonacci. An easy LeetCode question, right?”
Me: “Yeah, you should have smashed that. You’ve been practicing LeetCode for months.”
X: “I thought so too. I first showed him the classic recursion approach. Then he asked, ‘Do you know other ways to solve it more effectively?’”
Me: “Oh, so what did you do?”
X: “I wrote a loop version. He said, ‘Good. But can you still use recursion and make it more efficient?’ I had no idea what he meant.”
Me: “Ah, he was hinting at Tail Call Optimization (TCO).”
X: “Yeah, he asked me if I knew TCO. I said no.”
Me: “Forget this team, bro. TCO isn’t a programming technique; it’s a language feature. The interviewer was just flexing.”
Let me break this down for you, and anyone else puzzled by the same.
The TCO
The What
Tail Call Optimization (TCO) is a feature in some programming languages to optimize recursive function calls by “reusing” stack frames instead of creating new ones.