A monotonic array is an array whose elements, from left to right, are entirely non increasing, or entirely non decreasing. Return true if the given array is monotonic.
[-1, -5, -10, -1100, -1100, -1101, -1102, -9001]
All the elements in the input array are strictly non increasing.
Click to reveal
Can you try solving this problem in linear time without using any additional space?
Can you figure out increasing and decreasing cases separately?