#K48142. Contains Nearby Duplicate

    ID: 28355 Type: Default 1000ms 256MiB

Contains Nearby Duplicate

Contains Nearby Duplicate

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

\( nums[i] = nums[j] \quad \text{and} \quad |i - j| \le k \)

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

Note: The array indices are considered in a 0-based manner.

inputFormat

The input is given via standard input in the following format:

  1. An integer n denoting the number of elements in the array.
  2. A line with n integers separated by spaces, representing the elements of the array nums.
  3. An integer k representing the maximum allowed index difference.

outputFormat

Output a single line to the standard output: True if there exists a duplicate number such that the indices difference is at most k, otherwise False.

## sample
4
1 2 3 1
3
True

</p>