Pocket Gems interview question

LCA with O(N)