Pergunta de entrevista da empresa MongoDB

Simple coding question involving binary search