data_structures.arrays.monotonic_array¶
Functions¶
|
Check if a list is monotonic. |
Module Contents¶
- data_structures.arrays.monotonic_array.is_monotonic(nums: list[int]) bool ¶
Check if a list is monotonic.
>>> is_monotonic([1, 2, 2, 3]) True >>> is_monotonic([6, 5, 4, 4]) True >>> is_monotonic([1, 3, 2]) False >>> is_monotonic([1,2,3,4,5,6,5]) False >>> is_monotonic([-3,-2,-1]) True >>> is_monotonic([-5,-6,-7]) True >>> is_monotonic([0,0,0]) True >>> is_monotonic([-100,0,100]) True