Jupiter Money interview question

Leetcode hard on binary search.