Search topics...
All Problems

Monotonic Array

Solution Approach
Was this helpful?
EasyarrayExpected: O(n) time, O(1) space

Problem

Given an array, return true if it is monotone increasing or monotone decreasing.

Example 1:

Input: nums = [1, 2, 2, 3]
Output: true
Explanation: The array is monotone increasing.

Example 2:

Input: nums = [6, 5, 4, 4]
Output: true
Explanation: The array is monotone decreasing.

Example 3:

Input: nums = [1, 3, 2]
Output: false
Reference solution unlocks after your first submission
Loading...