← Unit 4 · all exercises
Saved in this browser only

Is it in order

Return true when the numbers never decrease from left to right. An empty array and a single item both count as sorted.

boolean isSorted(int[] values)

Solution.java
Loading editor…
Results

Examples

  • Solution.isSorted(new int[]{1, 2, 3}) → true
  • Solution.isSorted(new int[]{3, 1, 2}) → false

There are also 4 hidden tests you can't see. Solve the problem, not the examples.