Given an array of integers nums, return true when the values are in non-decreasing order, and false otherwise.
Is the Array Sorted? (Set 1) — the data. This set runs 4 cases: nums holds arrays of 3–7 items, with values from -17 to 18. The hidden cases are the largest of the set.
Example 1
isSortedAscending()
Input
nums =[-5,1,3,7,16]
Output
true
Why
`isSortedAscending` returns `true`forthisinput.
Example 2
isSortedAscending()
Input
nums =[-17,-14,0,11,18]
Output
true
Why
`isSortedAscending` returns `true`forthisinput.
Constraints
0<=nums.length<=10^5-10^4<= nums[i]<=10^4
Every caseinthisset 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.