# Delete Nodes from a Binary Tree (Java)

#### Watch someone solve the delete nodes from a binary tree problem in an interview with a Google engineer and see the feedback their interviewer left them. Explore this problem and others in our library of interview replays.

Java interview with a Google engineer: Delete nodes from tree - YouTube

### Interview Summary

**Problem type**  
Delete nodes from a binary tree

**Interview question**  
1) Debug this piece of code.  
2) We want to delete certain nodes from a binary tree. We have a function `shouldDelete(TreeNode node)` that returns true if we should delete that node, you can assume this function already exists.  
Write a function `deleteNodes(TreeNode root)` that takes a binary tree which removes the nodes that should be deleted from the tree and returns a forest of trees.

### Interview Feedback

**Feedback about Kind Ibex (the interviewee)**

**Advance this person to the next round?**  
 Yes

**How were their technical skills?**  
3/4

**How was their problem solving ability?**  
3/4

**What about their communication ability?**  
3/4

> You have a good methodical and logical approach to problem solving, I don't have any suggestion here, good job.  
> **Communication:**  
> Explain your approach to the interviewer before you start writing code, it is a good idea to bring up the time complexity of your solution as well.  
> Don't feel obligated to step through your code out loud.  
> **Coding:**  
> Keep your indentation consistent.  
> Use a helper function if you need to when writing recursive functions.  
> It is more typical to use an interface type for the return value of a function instead of a concrete type, e.g. `List` instead of `ArrayList`.

**Feedback about Talking Fox (the interviewer)**

**Would you want to work with this person?**  
 Yes

**How excited would you be to work with them?**  
4/4

**How good were the questions?**  
4/4

**How helpful was your interviewer in guiding you to the solution(s)?**  
4/4

> You were the first interviewer who focused more on the thought process than speed. It makes me feel better so thank you on that. You had a good exercise in the beginning to break the ice so that was good too.

### Interview Transcript

**Talking Fox:** Hello.  
**Kind Ibex:** Hi can you hear me alright?  
**Talking Fox:** Hi. Is this a good time for you? It will take about 45 minutes.  
**Kind Ibex:** Oh yeah, I was waiting for you.  
**Talking Fox:** Okay so let's start by doing some introductions and then taking a look at some code.  
**Kind Ibex:** Okay.  
**Talking Fox:** So I can start by telling you a bit about myself. So I was a software engineer at Google for about six years. I worked a lot of the time in Geo, so I worked on like the Maps front end and I worked on the android client for location sharing.  
**Kind Ibex:** Okay.  
**Talking Fox:** So you can stay anonymous if you want or you can tell me a bit about yourself either.  
**Kind Ibex:** So I actually work in Intel. I graduated last year and right now working in the devops team for a year. I have my essary interview day after at Google, so I am just trying to see if I can make it this time.  
**Talking Fox:** Sure umm so for the essary interviews, you do like some coding interviews and then some other more like essary specific ones right?  
**Kind Ibex:** Yeah but for me I think it's like, I don't have a lot of experience so it's just holding down.  
**Talking Fox:** Oh, interesting.  
**Kind Ibex:** One behavior, that's it. Leadership round.

... [the transcript continues]

---

This content was cleaned to retain only the main semantic elements while removing non-semantic elements. The interview feedback and details regarding the coding problem are kept intact.
