Amazon Interview Question: Given two nodes in a binary t... | Glassdoor

Interview Question

Software Development Engineer I Intern Interview Seattle, WA

Given two nodes in a binary tree, find their first common

  ancestor (if it exists).

Interview Answer

1 Answer


I just searched for each node as I went down the binary tree. As I went down to each level, I'd check if I could still reach both. If I couldn't then I return true for that node above.

Interview Candidate on Jun 7, 2017

Add Answers or Comments

To comment on this, Sign In or Sign Up.