What does comparator do in the money change problem , when we used lower bound function without comparator it gave the next or equal value of key but what will comparator will return ? please explain with an example
What does comparator return here?
Hey, comparator will not return anything. It is used to change the order in which we want things to be sorted first then apply lower bound.
Normally things are stored in ascending order but what if you want descending or any other order, then you can pass comparator to sort it according to the way you want and apply lower bound to values sorted in that order only and not default order.