FunctionRacerProblemsRace

Monotonic Array

EasyArraysPython, JavaScript, TypeScript, Java, C++

A list is monotonic if it never goes down (non-decreasing) or it never goes up (non-increasing). Equal neighbours are fine.

Return True if nums is monotonic, otherwise False.

Example 1

nums [1,2,2,3]
returns true

Never goes down.

Example 2

nums [1,3,2]
returns false

It goes up, then down.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Arrays problems