Conclusion for Contains Duplicates problem


  • 0
    J

    Contains Duplicate 1
    Contains Duplicate Question: abs(nums[j] – nums[i]) = 0
    Tips: HashSet<num>

    Contains Duplicate 2
    Contains Duplicate Question:abs(nums[j] – nums[i]) = 0 and abs(idx_j – idx_i) <= k
    Tips: Window -> set.size() <= k

    Contains Duplicate 2.5
    Contains Duplicate Question: abs(nums[j] – nums[i]) = t and abs(idx_j – idx_i) <= k
    Tips: set.add(Math.abs(nums[i]-t))

    Contains Duplicate 3
    Contains Duplicate Question: abs(nums[j] – nums[i]) <= t and abs(idx_j – idx_i) <= k
    Tips: Map<id, num>
    id -> group id -> used for roughly check abs(nums[j] – nums[i]) <= t
    num -> num value -> used for accurately check abs(nums[j] – nums[i]) <= t

    inspired by leetcode community


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.