Comparator in Lower bound

ower bound function pe a<=b comparator lgane k baad and 100 input pe 200 return kiya.
lower bound function pe a<=b comparator lgane k baad and 168 input pe 200 return kiya.

how???

yes @pranavshukla1011 you are correct . actually using comp a less than eq b in lowerbound just converts it into upperbound .
hope its clear if yes dont forget to mark resolved and hit like :smiley:

a[]={60, 100, 200} and lowerbound with comparator a<=b and ele=168.

how can the element still return 200

as you can see it is returning strictly greater value and def-
lower_bound returns an iterator pointing to the first element in the range [first,last) which has a value not less than ‘val’. upper_bound returns an iterator pointing to the first element in the range [first,last) which has a value greater than ‘val’. so a<=b syntax also helps in obtaining greater thats why behaves like upper

ele = 168 so greater value is 200

60 and 100 are less than 168 and 200 is greater than 168.

@sdevwrat but you used comparator a<=b which converts lower to upper thats why 200

@sdevwrat also lowerbound gives >= value so
without comp if key=100 ans 100 and if key = 168 ans 200
with comp if key 100 ans 200 and if key 168 ans 200

yes what you are saying is correct so where you are getting doubt.

@sdevwrat sry its just a misunderstanding i thought you were asking the doubt but @pranavshukla1011 was asking :smiley:

@vatsal38 same here :smile:, sorry.