Part I: An interview gone horribly wrong
(If you hate tech satire, skip to Part II)
You’re sitting in a cramped room with a glass door in $TRENDY_CO’s headquarters. It’s the final interview of the day, your last chance to make a case that you deserve the job.
A mid-20s tech-bro wearing a $TRENDY_CO t-shirt, who you assume to be the interviewer, enters the room. You exchange pleasantries. The interviewer steals glances at your resume (probably the first time he’s seen it). A few minutes later, he announces that it’s time to “start off with some technical questions.” You nod in solemn agreement: After all, this is what you signed up for.
The interviewer proceeds with the first question. “You’re given a pointer to the root node of the tree…”
As soon as you hear “tree”, a word pops into your head.
You keep thinking to yourself, “I NEED TO USE RECURSION” to the point that you forget the interviewer is speaking.
Once you catch yourself drifting off, you ask the interviewer to repeat the question.
“You’re given a pointer to the root node of a binary tree. I want you to write an algorithm to invert the binary tree, so the left child of a node is now the right child, and vice versa.”
OK… so you think you can solve the problem using recursion. Now what?
No algorithm immediately comes to mind, so you try to draw inspiration from other recursive problems. A few classic textbook recursion problems come to mind: in-order traversal, towers of Hanoi, n-queens.
The only problem is that you don’t really know how those work. After all, who really pays attention in their algorithms class?
Your blood pressure and heart rate start to rise.
When the interviewer asks you what you’re thinking, you start stammering and offering drawn out “uhhhhs.”
Now your mind is in full panic mode, and your vision starts to blur.
In desperation, you take a whiteboard marker and start writing some (nonsensical) code while muttering to yourself about base cases and recursive cases. The interviewer furrows his brows and loudly sighs, expecting this interview to be yet another waste of his time. Every second feels like an eternity of torment, as you watch your interview hopes go down in flames.
After an agonizing 25 minutes, the interviewer decides to take mercy on you and ends the technical portion of the interview early. He asks if you have any questions about the company to which you respond with generic questions about the culture and work-life balance at $TRENDY_CO.
Once the interview concludes, you make a beeline for $TRENDY_CO’s exits. You’re so mortified of your interview that you can’t make eye contact with anyone for the rest of the day. Later that night, you go on Hacker News to read posts ranting about the sad state of affairs in tech interviewing (maybe even leaving a comment or two yourself).
Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fuck off.
— Max Howell (@mxcl) June 10, 2015
(If you’re reading this Max, I love homebrew)