#K1901. Contains Nearby Duplicate

    ID: 24617 Type: Default 1000ms 256MiB

Contains Nearby Duplicate

Contains Nearby Duplicate

Given an integer array nums and an integer k, determine whether there exist two distinct indices i and j in the array such that nums[i] = nums[j] and the distance between them satisfies the inequality \(|i - j| \leq k\). In other words, check if the array contains duplicate elements with their indices at most k apart.

Your task is to read the input from stdin and print the result to stdout. The output should be exactly True if such a pair exists, or False otherwise.

inputFormat

The first line of input contains two integers n and k separated by a space, where n is the number of elements in the array and k is the maximum allowed distance between duplicate elements.

The second line contains n space-separated integers, representing the array nums.

outputFormat

Print True if there exist two duplicate numbers within a distance k (i.e. \(|i - j| \leq k\)), otherwise print False.

## sample
4 3
1 2 3 1
True