输出不匹配的坏键,全大写,不重复
1. 原文
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.
Now given a string that you are supposed to type, and the string that you actually type out, please list those keys which are for sure worn out.
Input Specification:
Each input file contains one test case. For each case, the 1st line contains the original string, and the 2nd line contains the typed-out string. Each string contains no more than 80 characters which are either English letters [A-Z] (case insensitive), digital numbers [0-9], or _
(representing the space). It is guaranteed that both strings are non-empty.
output Specification:
For each test case, print in one line the keys that are worn out, in the order of being detected. The English letters must be capitalized. Each worn out key must be printed once only. It is guaranteed that there is at least one worn out key.
Sample Input:
1 | 7_This_is_a_test |
Sample output:
1 | 7TI |
2. 解析
统计第二个字符串的每个字符,exist[str2[i]]++;
遍历第一个字符串的每个字符,没被访问过,答案中也没有则加入答案
1 | if(exist[str1[i]]==0&&ans.find(str1[i])==string::npos){ |
3. AC代码
1 |
|
Way2:
1 |
|