Help in c++ stl

what is difference between lower_bound(a.begin(),a.end(),value) and a.lower_bound(value).
these are my two solution sol1 sol2 using above function one is giving AC(using a.lower_bound(value)) other is giving TLE(using lower_bound(a.begin(),a.end(),value))

I’m a bit sleepy at the moment, but could be this.


It is general lower bound function which could be used for many containers. For random access iterators its time complexity is log n for others its n. Your are using set and it can’t be randomly accessed ,i.e ,you can’t use index to access the values in the set.

This lower bound function is specific to the container used (Using the dot operator implies you are using container specific function) . The lower bound implemented for set has a time complexity of log n.

okay i got it thanks

1 Like

it’s helpful thanks