Domanda di colloquio di Amazon

A difficult question about binary trees