Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at most t and the difference between i and j is at most k.
classSolution(object):defcontainsNearbyAlmostDuplicate(self,nums,k,t):""" :type nums: List[int] :type k: int :type t: int :rtype: bool """ifk<1ort<0:returnFalseDict=collections.OrderedDict()forxinrange(len(nums)):key=nums[x]/max(1,t)# only check three optionsformin(key-1,key,key+1):ifminDictandabs(Dict[m]-nums[x])<=t:returnTrueDict[m]=nums[x]ifx>=k:Dict.popitem(last=False)returnFalse