in finding the index of upperbound we first find the address of upper bound
it=upper_bound(a,a+n,key)
and then (it-a-1).why -1,in lower bound we simply subtract (it-a).here why do we subract with -1?
Find lower and upper bound
@anitagupta1411 you can do anything -1 +1 acc to the question just need to know lower bound returns the iterator to element if it is present else return iterator of value greater than to be searched.
upperbound always return greater.
i hope its clear if yes dont forget to hit like and mark resolved 
https://online.codingblocks.com/app/player/127473/content/109889/5048/code-challenge here in this qn if we write it-a then it will fail but if we write it-a-1 then pass .why?this was my doubt
@anitagupta1411 cant open the question but if doing -1 gives correct then it must be due to indexing issues like if your array is 1 indexed then i dont think -1 is required just study the def of both upper and lower and try on you system values for diff inputs
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.