Pergunta de entrevista da empresa Apple

Got asked a binary search iterator question from leetcode, got asked both the recursive and the iterative approach