Tap here to switch tabs
Problem
Submissions

Problem: Contains Duplicate III

Contains Duplicate III asks whether an integer array has two distinct positions within a given index distance whose values differ by no more than a given value distance, returning true or false.

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

Contains Duplicate III asks whether an integer array has two distinct positions within a given index distance whose values differ by no more than a given value distance, returning true or false.

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