Nathan_McKane's blog

By Nathan_McKane, history, 4 years ago, In English

I was trying a question on searching/sorting (Problem link) and i defined my own comparator for in-built sort(). It produced ambiguous output for the input (Error Code Link). However, when i changed the "<=" to "<" in my comparator, the code (Accepted Code Link) worked properly and was accepted. I dont know how this happened and what was the significance of changing the comparison condition.

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

»
4 years ago, # |
  Vote: I like it +19 Vote: I do not like it

Maybe this will help

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

Here, here, here, and many more.