P14275 [GeeksforGeeks] Camelcase pattern matching2259
普及
题目描述

Given a dictionary of words where each word follows CamelCase notation, print all words (in lexicographical order) in the dictionary that match with a given pattern consisting of uppercase characters only.
Example: GeeksForGeeks matches the pattern "GFG", because if we combine all the capital letters in GeeksForGeeks they become GFG. Also note "GeeksForGeeks" matches with the pattern "GFG" and also "GF", but not matches with "FG".
CamelCase is the practice of writing compound words or phrases such that each word or abbreviation begins with a capital letter. Common examples include PowerPoint and Wikipedia, GeeksForGeeks, CodeBlocks, etc.
Example 1:
Input:
N=3
Dictionary=["WelcomeGeek",
"WelcomeToGeeksForGeeks","GeeksForGeeks"]
Pattern="WTG"
Output:
WelcomeToGeeksForGeeks
Explanation:
Since only WelcomeToGeeksForGeeks matches
the pattern, it is the only answer.
Example 2:
Input:
N=8
Dictionary=["Hi","Hello","HelloWorld",
"HiTech","HiGeek","HiTechWorld",
"HiTechCity","HiTechLab"]
Pattern="HA"
Output:
-1
Explanation:
Since the pattern matches none of the words
of the string,the output is -1.
Your Task:
You don't need to read input or print anything. Your Task is to complete the function CamelCase() which takes an integer N, a Vector of strings Dictionary and a string Pattern and returns the strings in the dictionary that match the pattern, if not found any return -1.
Expected Time Complexity: O(N|S|) S=Longest string in Dictionary
Expected Auxillary Space: O(26
N)
Constraints:
1<=N<=1000
1<=|S|<=100
1<=|Pattern|<=|S|<=100
S is the longest word in Dictionary.

输入格式

见题面

输出格式

见题面

样例输入
N=3 Dictionary=["WelcomeGeek", "WelcomeToGeeksForGeeks","GeeksForGeeks"] Pattern="WTG"
样例输出
WelcomeToGeeksForGeeks