AdobeOA #4
Partition Array into Equal-Length Distinct Subsequences
Estimated EasyJudge-ready
Topics (AI-labelled)Hashing
Put every array element into exactly one subsequence of length k so that the values within each group are pairwise distinct; subsequences keep the original index order but need not be contiguous.
Input
The first line contains n k, and the second line contains n integers. OCR004 gives the definition and 005 completes the original bounds: 1≤n≤100000, 1≤k≤n, 1≤a[i]≤100000.
Output
Output Yes or No.
Example 1
Input:
4 2
1 2 3 4
Output:
Yes
Example 2
Input:
4 3
1 2 2 3
Output:
No
Example 3
Input:
4 2
3 5 3 2
Output:
Yes
Example notes
The outputs of the three public examples are, in order: Yes; No; Yes. Verified by independent enumeration or direct simulation.
Editorial
Loading solution…