Couldn't understand the code

I cannot understand the code for lower and upper bound

@hsangwan941_4f8d090387e9ffd8 Bro the code is same as the code of binary search. In binary search when the condition arr[mid]=data then we just return the answer but now we can have one or more indexes which contain data as its entry so we can have lowerbound and upperbound so we can not just return the answer we have to compute till last and then return the answer. Dry run the code yourself.

1 Like

Thank you so much ! Easy to understand. :))

@hsangwan941_4f8d090387e9ffd8 :+1: