Tap here to switch tabs
Problem
Submissions

Problem: Contains Duplicate III

Try to solve the Contains Duplicate III problem.

Statement

Given an integer array nums and two integers indexDiff and valueDiff, determine if there exist two distinct indices i and j such that:

  • i ≠\neq j

  • abs(i - j) ≤\leq indexDiff

  • abs(nums[i] - nums[j]) ≤\leq valueDiff

Return true if such a pair of indices exists, or false otherwise.

Constraints:

  • 2≤2 \leq nums.length ≤105\leq 10^5

  • −109≤-10^9 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq indexDiff ≤\leq nums.length

  • 0≤0 \leq valueDiff ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Contains Duplicate III

Try to solve the Contains Duplicate III problem.

Statement

Given an integer array nums and two integers indexDiff and valueDiff, determine if there exist two distinct indices i and j such that:

  • i ≠\neq j

  • abs(i - j) ≤\leq indexDiff

  • abs(nums[i] - nums[j]) ≤\leq valueDiff

Return true if such a pair of indices exists, or false otherwise.

Constraints:

  • 2≤2 \leq nums.length ≤105\leq 10^5

  • −109≤-10^9 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq indexDiff ≤\leq nums.length

  • 0≤0 \leq valueDiff ≤109\leq 10^9