Pocket Gems Interview Question

LCA with O(N)