Back to the 100
Course Practice
Hard

Contains Duplicate III

LAB

Return true if two different indices are within indexDiff positions and their values differ by at most valueDiff.

EXAMPLES

Example 1
Input
{
  "nums": [
    1,
    2,
    3,
    1
  ],
  "indexDiff": 3,
  "valueDiff": 0
}

Output
true

FUNCTION SHAPE

nums: intArrayindexDiff: intvalueDiff: intbool
00:00
3 local tests readyRun with ⌘/Ctrl + Enter. Your code stays in this browser.

Runs solve(...) locally in a browser worker. SWE Playbook does not submit your code. Only run code you trust; Python code may access the network.