DoorDash interview question

A LC question related to binary search