@@ -0,0 +1,1046 @@
+class Solution(object):%0A    def findClosestElements(self, arr, k, x):%0A        %22%22%22%0A        :type arr: List%5Bint%5D%0A        :type k: int%0A        :type x: int%0A        :rtype: List%5Bint%5D%0A        %22%22%22%0A        larr = len(arr)%0A        L, U = -1, larr%0A        while L + 1 %3C U:%0A            mid = L + (U - L) / 2%0A            if arr%5Bmid%5D %3E x:%0A                U = mid%0A            else:%0A                L = mid%0A        Lary, Uary = %5B%5D, %5B%5D%0A        while len(Lary) + len(Uary) %3C k:%0A            Lcand, Ucand = None, None%0A            if L %3E= 0:%0A                Lcand = arr%5BL%5D%0A            if U %3C larr:%0A                Ucand = arr%5BU%5D%0A            if Lcand is None:%0A                Uary.append(Ucand)%0A                U += 1%0A            elif Ucand is None:%0A                Lary.append(Lcand)%0A                L -= 1%0A            else:%0A                if abs(Lcand - x) %3C= abs(Ucand - x):%0A                    Lary.append(Lcand)%0A                    L -= 1%0A                else:%0A                    Uary.append(Ucand)%0A                    U += 1%0A        return Lary%5B::-1%5D + Uary%0A

Add py solution for 658. Find K Closest Elements