Question d’entretien chez Oracle

Algorithm question was Medium level leetcode one.