Pregunta de entrevista de Apple

Binary search optimisation question from leetcode