...

/

Solution: Contains Duplicate II

Solution: Contains Duplicate II

Let’s solve the Contains Duplicate II problem using the Sliding Window pattern.

Statement

You are given an integer array, nums, and an integer k. Determine whether two distinct indices, i and j, are in the array, such that nums[i] == nums[j] and the absolute difference between i and j is at most k. Return TRUE if such indices exist; otherwise, return FALSE.

Constraints:

  • 11 \leq ...

Access this course and 1400+ top-rated courses and projects.