Search⌘ K
AI Features

Contains Duplicate II

Explore how to determine if an array contains duplicate elements within a given distance using the sliding window technique. This lesson helps you understand problem constraints, identify the key pattern, and implement an efficient solution that checks for duplicates within a specified window size.

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 nums.length ...