Warm-ups · 3 of 24
Check if an array is sorted
Return true if the array is in non-decreasing order (each element ≤ the next), otherwise false.
Examples
Input nums = [1, 2, 2, 5]
Output true
Equal neighbours are allowed.
Input nums = [3, 1, 2]
Output false
📘 New to this? Indexing and walking through an array explains the idea in a few minutes.