Is the Array Sorted? (Set 13)

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 13) — the data. This set runs 4 cases: nums holds arrays of 10–40 items, with values from -20 to 20. The hidden cases are the largest of the set.

Example 1

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

Why

`isSortedAscending` returns `true` for this input.

Example 2

isSortedAscending()
Input
nums = [-20, -19, -13, -13, -12, -12, -12, -11, -8, -7, -2, -2, -2, -1, -1, 0, 0, 0, 1, 1, 2, 2, 4, 5, 6, 6, 8, 8, 8, 9, 10, 12, 12, 13, 15, 17, 18, 18, 19, 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.