Ad
  • Custom User Avatar

    Read the instructions again:

    (The highest/lowest element is respectively only one element at each edge, even if there are more than one with the same value!)

    The answer for {3, 3} is 0.

  • Custom User Avatar

    Why test for two elements passes with something like that?

    if(numbers.size() == 2)
      return 0;
    

    Author decided that there are one max and one min values, for example {3, 10}, so result is 0, because we exclude max and min values in answer.
    Though, an array {3, 3} possible too. And answer should be 3.