题目:
题解:
class Solution(object):def containsNearbyAlmostDuplicate(self, nums, k, t):from sortedcontainers import SortedSetst = SortedSet()left, right = 0, 0res = 0while right < len(nums):if right - left > k:st.remove(nums[left])left += 1index = bisect.bisect_left(st, nums[right] - t)if st and index >= 0 and index < len(st) and abs(st[index] - nums[right]) <= t:return Truest.add(nums[right])right += 1return False