Always One Direction
A monotonic list keeps moving in one direction: it either never decreases or never increases. Equal neighboring values are allowed, so steps like 2, 2 do not break the pattern. Given nums, return True if it is monotonic, otherwise return False.
Примеры
Ввод
[1, 2, 2, 3]Вывод
TrueВвод
[6, 5, 4, 4]Вывод
TrueВвод
[1, 3, 2]Вывод
FalseНужно реализовать
def is_monotonic(nums):
Теги
array
Jelentkezz be a beküldési előzmények megtekintéséhez
BejelentkezésJelentkezz be az MI-mentor használatához
BejelentkezésVisible tests
1
Input
[1,2,2,3]Expected
True2
Input
[6,5,4,4]Expected
True3
Input
[1,3,2]Expected
False4
Input
[1,1,1]Expected
True5
Input
[1]Expected
True6
Input
[1,2,4,5,0]Expected
FalseFocus radio
Paused · SomaFM · Fluid