Practice Contains Duplicate III
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Return whether nums contains two different positions i and j satisfying both abs(i - j) <= indexDiff and abs(nums[i] - nums[j]) <= valueDiff. Both distance limits are inclusive; one element cannot be paired with itself.
Source: Contains Duplicate III on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [1,2,3,1], indexDiff = 3, valueDiff = 0
Output
true
# Example 2
Input
nums = [1,5,9,1,5,9], indexDiff = 2, valueDiff = 3
Output
false
Constraints
2 <= nums.length <= 10^5
-10^9 <= nums[i] <= 10^9
1 <= indexDiff <= nums.length
0 <= valueDiff <= 10^9
Related LeetCode Problems
Practice more problems similar to Contains Duplicate III.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.