描述
给出两个字符串,你需要找到缺少的字符串
样例
输入 : str1 = “This is an example”, str2 = “is example”
输出 : [“This”, “an”]
思路
使用unordered_set来保存str2中的字符串,然后遍历str1中的字符串,如果不存在在set中,那么就加入到结果的数组当中
这里使用到了stringstream的操作。
代码
1 | class Solution { |
-------------end of filethanks for reading-------------