Why we didnt use upper_bound

The question could have been solved without making the comparator function and overcomplicating it instead could have used upper_bound and removed the compare function inside of it.
as upper bound gives normally the element next to it so naturally we have to minus one and their would have been no problem around the edge cases.

Hello @adityasingh1290
Yeah we can use upper bound as well.
With. This Video bhaiya wants to show that we can modify working of these functions as per our need