Ad
  • Default User Avatar

    "Focus on efficiency" at the end of kata description is the hint what you shoud do.
    You'll have to optimize your code...

  • Default User Avatar

    "Process was terminated. It took longer than 12000ms to complete" doesn't always mean that all tests were passed; nevertheless refactoring your code might be useful.

  • Default User Avatar

    That's part of the definition of what the median is: it's the middle value of a sorted data set.

  • Custom User Avatar

    You cannot determine a mean without sorting the array.

    But it is good practice to sort a copy of the input array, so you don't change the input array itself.

    Most people don't bother with that precaution in this kata (I didn't), and the tests are unaffected. (Yes, this means the tests are designed better than most solutions.)

  • Default User Avatar

    mean = (-10 + 20 + 5) / 3 = 5

    median = {-10, 5, 20}[1] = 5

    result = same

  • Custom User Avatar

    Median is 5. (You have to sort the values.)
    Mean is 5.

    Does this answer your question?