利用选择排序法
import java.util.ArrayList;

public class Solution {
public ArrayList<integer> GetLeastNumbers_Solution(int [] input, int k) {
ArrayList<integer> res = new ArrayList<>();
if(k == 0) return res;
else
for(int i = 0;i<k;i++){
int minIndex = i;
for(int j = i+1;j<input.length;j++){
if(input[minIndex]>input[j]) minIndex = j;
}
if(minIndex != i){
int temp = input[i];
input[i] = input[minIndex];
input[minIndex] = temp;
}
res.add(input[i]);
}
return res;
}
}</integer></integer>