Is the Array Sorted? (Set 8)

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

Example 1

isSortedAscending()
Input
nums = [-20, -20, -19, -15, -15, -13, -11, -11, -11, -9, -8, -6, -5, 0, 2, 16, 16, 18]
Output
true

Why

`isSortedAscending` returns `true` for this input.

Example 2

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

Why

`isSortedAscending` returns `false` 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.