Check if an Array is Sorted
The Check if an Array is Sorted problem involves determining whether the elements of an array are arranged in non-decreasing order.
Given an integer array arr[] of size n, return true if the array is sorted in non-decreasing order; otherwise, return false.
Note: An array is considered sorted if every element is less than or equal to its next element.
Example 1
Input
arr[] = [1,2,3,4,5]
Output
true
Explanation
Example 2
Input
arr[] = [2,5,1,8,9]
Output
false
Explanation
Constraints
Hints:
Hint 1
Author & Technical Reviewer
Technically reviewed by: ExamAdda Technical Review Team
Technical Reviewers, ExamAdda
Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.
Published
Jun 29, 2026
Last updated
Aug 6, 2026
Content Verification Methodology
Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.
Expected Output