Easy · Arrays

Selection sort

Given an integer array nums, sort it in place into non-decreasing order with selection sort (repeatedly swapping the minimum of the unsorted suffix into the next position); the function returns nothing.

Examples

Example 1

[5, 2, 8, 1, 9, 3]

Output: [1, 2, 3, 5, 8, 9]

Example 2

[7, 6, 5, 4, 3] · worst

Output: [3, 4, 5, 6, 7]

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Arrays problems