Amazon Interview Question

Given two nodes in a binary tree, find their first common ancestor (if it exists).

Interview Answer

Anonymous

Jun 7, 2017

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.