Pregunta de entrevista de Amazon

Find common ancestor LC problem