#K12956. Nearby Duplicate Checker

    ID: 23805 Type: Default 1000ms 256MiB

Nearby Duplicate Checker

Nearby Duplicate Checker

You are given an array of integers nums and an integer k. Your task is to determine whether there exists two distinct indices \(i\) and \(j\) in the array such that:

\(nums[i] = nums[j]\) and \(|i - j| \le k\)

If such a pair exists, output True, otherwise output False.

Note: The condition \(|i - j| \le k\) means that the absolute difference between the indices is at most \(k\).

inputFormat

The input is given in two lines:

  1. The first line contains two space-separated integers n and k, where n is the number of elements in the array.
  2. The second line contains n space-separated integers representing the array nums.

outputFormat

Output a single line with True if there exists a pair of indices satisfying the conditions, otherwise output False.

## sample
4 3
1 2 3 1
True