incorrect lower bound

Why lower_bound is not returning correct output in this here.
code is for LOSTMAX question in July Lunchtime

vector<int>::iterator it=lower_bound(vs.begin(),vs.begin(),sz-1);

Check the bounds you used on the lowerbound, it’s “vs.begin(), vs.begin()”; One of then should be vs.end() :stuck_out_tongue:

1 Like

Can you tell me why are you suddenly resizing the vs? I mean…how do you know which element will get deleted?

actually when we r using istringstream it inserts a blank at the end of input so to remove that extra blank we have to resize it i read it somewhere on stack overflow

i have checked by reprinting the vector after sorting and resizing it is absolutely fine the problem is with lower bound

Ohk, lemme check again then.

ohhh god why btw thanks