package main

/**
 * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
 * 
 * @param input int整型一维数组 
 * @param k int整型 
 * @return int整型一维数组
*/
func GetLeastNumbers_Solution( input []int ,  k int ) []int {
    // write code here
    sort(input, 0, len(input) - 1)
    
    return input[0:k]

    
}


func sort(input []int, low, high int) {
	if low >= high {
		return
	}

	left := low
	right := high
	target := input[left]
	for  left < right && right < len(input) {
		for left < right && input[right] >= target {
			right--
		}
		for left < right && input[left] <= target  {
			left++
		}

		if left < right {
			tmp := input[left]
			input[left]  = input[right]
			input[right] = tmp
		}
	}
	tmp := input[left]
	input[left]  = input[low]
	input[low] = tmp
	sort(input, low, left - 1)
	sort(input, left + 1, high)
}