<doocs>0658.Find K Closest Elements_1.py
def findClosestElements( arr: List[int], k: int, x: int) -> List[int]:
    left, right = 0, len(arr) - k
    while left < right:
        mid = (left + right) >> 1
        if x - arr[mid] <= arr[mid + k] - x:
            right = mid
        else:
            left = mid + 1
    return arr[left : left + k]
def sample_funcname ( var_0 : List [ int ] , var_3 : int , var_4 : int ) -> List [ int ] :
    var_6 , var_8 = 0 , len ( var_0 ) - var_3
    while var_6 < var_8 :
        var_10 = ( var_6 + var_8 ) >> 1
        if var_4 - var_0 [ var_10 ] <= var_0 [ var_10 + var_3 ] - var_4 :
            var_8 = var_10
        else :
            var_6 = var_10 + 1
    return var_0 [ var_6 : var_6 + var_3 ]
