import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Queue;

public class Solution {
    public ArrayList<Integer> GetLeastNumbers_Solution(int[] input, int k) {
        ArrayList<Integer> res = new ArrayList<>();
        if(k > input.length || input == null || input.length == 0 || k == 0) return res;

        Queue<Integer> queue = new PriorityQueue<>(k);
        for(int item : input){
            queue.add(item);
        }
        for(int i = 0; i < k; ++i){
            res.add(queue.poll());
        }
        return res;
    }
}