Is the Array Sorted? (Set 12)

Easy

Given an array of integers nums, return true when the values are in non-decreasing order, and false otherwise.

Is the Array Sorted? (Set 12) — the data. This set runs 4 cases: nums holds arrays of 9–48 items, with values from -20 to 20. The hidden cases are the largest of the set.

Example 1

isSortedAscending()
Input
nums = [-18, 9, 17, 19, -1, 10, 14, 14, 13, 9, 11, 2, -13, 19, 16, -9, -6, 5, -11, 17, -19, -10, -8, 8, -9, 10, -15, 20, -2, -1, 14, -15, -13, 5, 13, -17, -13, 13, 5, 20, 11, 3, 16, 11, -2, -4, -7, -20]
Output
false

Why

`isSortedAscending` returns `false` for this input.

Example 2

isSortedAscending()
Input
nums = [-18, -17, -15, -12, -12, -11, -10, -10, -6, 1, 4, 5, 5, 12, 15, 16, 16, 18, 20]
Output
true

Why

`isSortedAscending` returns `true` for this input.
Constraints
0 <= nums.length <= 10^5
-10^4 <= nums[i] <= 10^4
Every case in this set must pass: the first two are visible on Run, the last two unlock on Submit.

Topics

Arrays

Implement isSortedAscending in the editor and return the answer — printing it is never graded.