Sort Integers
ID: 463; naive
Solution 1 (Java)
public class Solution {
/**
* @param A: an integer array
* @return: nothing
*/
public void sortIntegers(int[] A) {
for (int i = 0; i < A.length; i++) {
int minIndex = i;
for (int j = i; j < A.length; j++) {
if (A[j] < A[minIndex]) {
minIndex = j;
}
}
int temp = A[i];
A[i] = A[minIndex];
A[minIndex] = temp;
}
}
}Notes
Solution 2 (Java)
Notes
Solution 3 (Java)
Notes
Last updated