DeloitteOA #3
Maximum Strings Buildable from at Most K Letters
Estimated MediumJudge-ready
Topics (AI-labelled)EnumerationBits & Math
Choose at most K letters from a–j (chosen letters can be reused); find the maximum number of the given strings that can be built completely.
This site's standard input/output format and any supplementary ranges follow this problem's description.
Input
The first line contains n K (1≤n≤100000, 0≤K≤10); each of the next n lines is a non-empty lowercase string containing only a–j. The total length is ≤200000 (site supplement).
Output
Output the maximum number of strings that can be built.
Example 1
Input:
5 3
adf
jjbh
jcg
eijj
adf
Output:
2
Example 2
Input:
2 3
abcd
efgh
Output:
0
Example 3
Input:
5 4
bc
edf
fde
dge
abcd
Output:
3
Editorial
Loading solution…