#C8037. Exact K Distinct Characters
Exact K Distinct Characters
Exact K Distinct Characters
You are given a string S consisting of lowercase English letters and an integer K. Your task is to determine whether it is possible to obtain exactly K distinct characters by removing some characters from the string.
In other words, let \(d(S)\) be the number of distinct characters in S. You should output YES
if \(d(S) \geq K\) (since you can remove all occurrences of some characters to leave exactly K distinct ones), and NO
otherwise.
inputFormat
The input consists of two lines:
- The first line contains the string S, which is composed of lowercase English letters.
- The second line contains a single integer K.
outputFormat
Output a single line containing YES
if it is possible to achieve exactly K distinct characters by removing some characters from S, and NO
otherwise.
abcabc
2
YES