Check if an Array Is Sorted

Given an integer array nums, return true when it is sorted in non-decreasing order. Otherwise, return false. Equal adjacent values are allowed. The empty…

Given an integer array `nums`, return `true` when it is sorted in non-decreasing order. Otherwise, return `false`. Equal adjacent values are allowed. The empty array and a one-element array are sorted because neither contains a decreasing pair.

- `0 <= nums.length <= 10^5` - `-10^9 <= nums[i] <= 10^9`

Example 1: input nums = [1,2,2,4]; output true. Every value is greater than or equal to the value before it.

Example 2: input nums = [1,3,2,4]; output false. The pair 3, 2 decreases from left to right.

Category: Arrays. Topic: arrays. Difficulty: Easy. Patterns: linear-scan.