FastPrepSort Values
Problems/Sort Values

Sort Values

AMD logoAMD● EasyFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report says an interviewer asked sorting programming questions, but names no algorithm, element type or ordering rule. This exercise uses integer values, ascending order, duplicates and a separate returned array. Approximate source match: 70%.

Given an integer array values, return a new array containing the same values in nondecreasing order. Keep every occurrence of a repeated value. Leave the input array unchanged.

Function

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

Examples

Example 1

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

Both occurrences of 1 remain. Each output value is at least the previous value.

Example 2

values = []return = []

An empty array has no values to reorder.

Example 3

values = [-4,0,-2]return = [-4,-2,0]

Negative values come before 0, ordered by their numeric value.

Constraints

  • 0 <= values.length <= 10000.
  • -2147483648 <= values[i] <= 2147483647.

More AMD problems

  • Insert After a Linked-List NodeONSITE INTERVIEW · Seen Oct 2026
  • LRU CacheONSITE INTERVIEW · Seen Oct 2026
  • Lowest Common Ancestor of a Binary TreePHONE SCREEN · Seen Oct 2026
All AMD interview questionsSee AMD hiring insights
Saved
public int[] sortValues(int[] values) {
    return new int[0];
}
Checking account…