Problem

In an array with at least three elements, replace the middle element with the larger of the first and last; return the array.

Examples

  • setMiddleMax([1, 5, 3]) -> [3, 5, 3]
  • setMiddleMax([8, 2, 10]) -> [10, 2, 10]
Compile and test (Ctrl+Enter)