Binary search normally finds an exact match. Here, you want the position where the target belongs, even if it's not in the array.
The trick: when binary search ends without finding the target, the left pointer points to the insertion position. Why? Because is the first index where .
This is a common pattern: binary search returns not just exact matches, but also boundary positions. You'll use this in many problems.