Selection Sort
Easyjavapythonccppjavascript
Sort an integer array in ascending order using Selection Sort — at each step, find the smallest remaining value and place it at the current position. The judge checks the final sorted output.
Input Format
The first line contains an integer N. The second line contains N space-separated integers.
Output Format
Print the N integers in ascending order, separated by single spaces, on one line.
Example 1
Input
5 64 25 12 22 11
Output
11 12 22 25 64
Explanation: The smallest remaining value is selected and placed each round.
- 1 <= N <= 100000
- -1000000000 <= A[i] <= 1000000000