Simplify. (TX) Interview Question

They give me a dsa problem based on binary search