Domanda di colloquio di Meta

basic algo question and 2nd one is more difficult