Ad
  • Default User Avatar

    I disagree. An array of the same numbers is sorted, but it is ambiguous what direction it is sorted.

  • Custom User Avatar

    because it's simpler to write/debug (overall) and that won't change a thing about the actual speed (time complexity is the same). Actually, if you time your code, you'll see that this one is way faster (I didn't check, but that's a safe bet) because of python's interpreter (using builtins function is faster, most of the time).

    so, less code, more readable, less occasions to do a typo, less to maintain, meaningfull way to handle the problem (="accumulate meaningful data, then use them"). So, definitely the way to go. ;)

    cheers