Question d’entretien chez Meta

Write a function to return minimum and maximum in an array. You program should make minimum number of comparisons. (less than O(2n))

Réponse à la question d'entretien

Utilisateur anonyme

29 sept. 2014

O(2n) is O(n)... The simple answer, just compare each value once and keep track of the max and min, replace if you find a new one. That only requires a single pass.

2