题目
Given two strings and is defined to be the remaining string after taking all the characters in from . Your task is simply to calculate for any given strings. However, it might not be that simple to do it fast.
Input Specification:
Each input file contains one test case. Each case consists of two lines which gives and , respectively. The string lengths of both strings are no more than . It is guaranteed that all the characters are visible ASCII codes and white space, and a new line character signals the end of a string.
Output Specification:
For each test case, print in one line.
Sample Input:
1 | They are students. |
Sample Output:
1 | Thy r stdnts. |
题解
思路
- 对第一行字符串的每个字符,如果它不在第二行当中,那么就输出它。
- 很显然用哈希集合。
数据结构
- a是第一行,字符串
- b是一个哈希集和,存放第二行每一个字符。
算法
- 先输入第一行
- 再输入第二行,建哈希集和
- 对每一个第一行的字符,判断其在不在第二行,不在就输出,注意后面不加空格。
代码
- 因为使用Python能够AC,因此只放了Python的代码。
1 | a = input() |