leecode220
作者:互联网
1 class Solution: 2 def containsNearbyAlmostDuplicate(self, nums: List[int], k: int, t: int) -> bool: 3 if t == 0 and len(set(nums)) == len(nums): 4 return False 5 for i,v in enumerate(nums): 6 for j in range(i+1, min(i+k+1,len(nums))): 7 if abs(nums[j]-nums[i])<=t: 8 return True 9 return False
此题目差评如潮,懒得自己做了。
参考:https://leetcode.com/problems/contains-duplicate-iii/discuss/514029/Python-3-O(n2)
标签:set,leecode220,nums,int,差评,len,enumerate 来源: https://www.cnblogs.com/asenyang/p/12640542.html