Question d’entretien chez Meta

2 algorithm question, the second one is harder.