Problem
Ask
Submissions

Problem: Contains Duplicate II

Medium
30 min
Explore how to apply the sliding window technique to find duplicate values within a specified index distance in an array. This lesson helps you understand problem constraints and implement an efficient solution to determine if such duplicates exist, improving your coding interview skills.

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 103\leq 10^3

  • 103-10^3 \leq nums[i] 103\leq 10^3

  • 00 \leq k 104\leq 10^4

Problem
Ask
Submissions

Problem: Contains Duplicate II

Medium
30 min
Explore how to apply the sliding window technique to find duplicate values within a specified index distance in an array. This lesson helps you understand problem constraints and implement an efficient solution to determine if such duplicates exist, improving your coding interview skills.

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 103\leq 10^3

  • 103-10^3 \leq nums[i] 103\leq 10^3

  • 00 \leq k 104\leq 10^4