#C4733. Contains Nearby Duplicate

    ID: 48304 Type: Default 1000ms 256MiB

Contains Nearby Duplicate

Contains Nearby Duplicate

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

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

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

Note: The indices are 0-based.

inputFormat

The input is given via stdin as follows:

  1. An integer n representing the number of elements in the array.
  2. A line with n space-separated integers representing the elements of the array nums.
  3. An integer k on a new line, representing the maximum allowed index difference.

outputFormat

Print a single line to stdout: True if there exists at least one pair of duplicate numbers satisfying the condition, otherwise False.

## sample
4
1 2 3 1
3
True