Pergunta de entrevista da empresa Apple

Got asked a binary search leetcode question.