# I Failed to Implement the Diameter of a Binary Tree in a Coding Interview

DevFeed: [I Failed to Implement the Diameter of a Binary Tree in a Coding Interview](<https://devfeed.tech/articles/i-failed-to-implement-the-diameter-of-a-binary-tree-in-a-coding-interview-20517.md>)

Original publisher: [Read original article](<https://code.dblock.org/2025/06/21/i-failed-to-implement-the-diameter-of-a-binary-tree-in-a-coding-interview.html>)

Author: Daniel Doubrovkine (dblock@dblock.org)

Published: 2025-06-21T01:00:00Z

Content type: opinion

Language: en

Sources: [Daniel Doubrovkine](<https://devfeed.tech/sources/daniel-doubrovkine.md>)

Topics: [LeetCode](<https://devfeed.tech/topics/leetcode.md>), [coding](<https://devfeed.tech/topics/coding.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [advice](<https://devfeed.tech/tags/advice.md>), [ai](<https://devfeed.tech/tags/ai.md>), [coding](<https://devfeed.tech/tags/coding.md>), [interview](<https://devfeed.tech/tags/interview.md>), [interviewing](<https://devfeed.tech/tags/interviewing.md>), [junior](<https://devfeed.tech/tags/junior.md>), [principal-engineer](<https://devfeed.tech/tags/principal-engineer.md>)

## AI overview

A Principal Engineer recounts freezing during a basic coding interview despite decades of programming experience. The article offers advice for recovering from interview failure, including maintaining perspective, practicing, and recognizing the role of luck in LeetCode-style interviews.

## Source excerpt

Six months ago I failed a basic coding interview at a FAANG. Yes, I was a Principal Engineer, and yes, I was paid absurd amounts of money, yet I couldn't implement a diameter of a binary tree as a "warm up" exercise, 10 lines of code. The interviewer was very nice about it, and was equally surprised. You see, I've been coding for 35 years, and I am not "rusty" at it, which is a typical excuse for senior ICs bombing LeetCode interviews. At that time I was writing code every day. I simply froze, and couldn't do it. All I could think of was "why the hell am I here doing this to myself?". I couldn't turn my brain around, apologized, cut the interview short, and, while I did ace several coding interviews at other companies for IC roles, went back to management for which I am, obviously, more qualified. Did you just bomb a coding interview? Here's some practical advice of how to deal with it. First, keep your head high and do not let this negative experience get to you. It feels awful, but unless you are blogging about your failure to implement the diameter of a binary tree, nobody other than you and the interviewer will ever know. Most likely the interviewer was also a half asleep drone deep inside the borg, administering a coding puzzle every day to the next sucker, so they will forget about you the next day. I see a lot of junior Engineers affected by failing at these. If you are recently out of college, it's helpful to think of these interviews as a school test, such as an SAT. I never had to take SATs (my children did), but most European schools have oral exams where you get a ticket from a jar with the problem statement. I had slept through too many alarms to attend an 8 AM physics class around 1996 because of a grueling late night partying schedule, and only really knew maybe half the material. Luckily 2/3 questions in my ticket overlapped with those classes I did attend, and so I did well. If you don't like school and prefer video games, think of these interviews