Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • actually, this custom comparator is very clever, so the sorting can be done in O(nlogn) instead of O(n^2).. even if you used qsort here :D

  • It's because numbers.size() returns a size_t (unsigned int), so when the array is empty numbers.size() - 1 is a large unsigned number (0xFFFFFFFF). Then the for loop executes that number of times and an invalid array index is used.