Question d’entretien chez Rakuten

A algorithm problem, medium difficulty