Meta Interview Question

A variation of LCA problem