sasamba_bitches's blog

By sasamba_bitches, history, 4 years ago, In English

I have already seen editorial, but getting WA. Here is the problem and this is my code. Can you please help me?

Thanks!

  • Vote: I like it
  • +8
  • Vote: I do not like it

»
4 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

In the function "thir" you can't write

auto it = s.lower_bound(x);
it--;

because maybe it == s.begin(). Instead of "it--" you can do "k--".

Also you should check that it != s.end(), before you do "it++" in the for loop.

And since the for loop might not be entered, you should also check that it != s.end() before you return *it in the end.