FastPrepSort an Integer Array in Ascending Order

Sort an Integer Array in Ascending Order

ZipRecruiter logoZipRecruiter● EasyNEW GRADOAONSITE INTERVIEW
Learn

Problem statement

Return the values of values in nondecreasing order. Duplicate and negative values are allowed.

Function

sortAscending(values: int[]) → int[]

Examples

Example 1

values = [1,2,4,3]return = [1,2,3,4]

The out-of-order final pair is corrected.

Example 2

values = [3,1,3,2]return = [1,2,3,3]

Equal values are retained.

Constraints

  • 0 <= values.length <= 100000
  • -1000000000 <= values[i] <= 1000000000

More ZipRecruiter problems

See ZipRecruiter hiring insights
public int[] sortAscending(int[] values) {
    // Write your code here.
}
values[1,2,4,3]
expected[1,2,3,4]
Checking account…