Question d’entretien chez Google

Question based on arrays, sorting n dp