Count Proper Prefix Matches
Problem statement
For each query string q, count the entries in names that start with q and are strictly longer than q. A name equal to the query does not count.
Return one count per query in the original query order. Repeated name entries count separately, and repeated queries are answered separately.
Function
countProperPrefixes(names: String[], queries: String[]) → int[]Examples
Example 1
names = ["steve","stevens","danny","steves","dan","john","johnny","joe","alex","alexander"]queries = ["steve","alex","joe","john","dan"]return = [2,1,0,1,1]steve matches stevens and steves, but not the equal name steve. alex matches alexander; joe has no strict extension; john matches johnny; dan matches danny.
Constraints
- 1 <= names.length <= 20000.
- 1 <= queries.length <= 200.
- Every name and query has length between2 and30.
- Every name and query contains only lowercase English letters.
- The total length of names is at most 5 * 10^6.