Longest Substring With Exactly K Unique Characters
easy
1. You are given a string(str) and a number K. 2. You have to find length of the longest substring that has exactly k unique characters. 3. If no such substring exists, print "-1".
Constraints
1 <= length of string <= 10^5 1 <= k <= 26
Format
Input
A string
Output
A number representing length of the longest K unique characters substring.
Example
Sample Input
aabcbcdbca
2
Sample Output
4
Question Video