i
to 0.i
until arr[i]
is no longer less than arr[i + 1]
or i
is equal to arr.length - 1
.i
is equal to 0 or i
is equal to arr.length - 1
, return false.i
while arr[i]
is greater than arr[i + 1]
.i
reaches arr.length - 1
, return true, indicating that a valid mountain has been traversed.i
reaches arr.length - 1
, return false, indicating that the array is not a valid mountain array.