京面问题:文字删除描述
给定两个字符串str和sub,你的任务是用str完全删除那些sub中存在的字符。
字符串中包含空格
1Len(str )、len (sub )10
5
在线评估地址
样例1
输入: str='They are students ',sub='aeiou '输入: ' thyrstdnts ' 3358 www.Sina.com /
在第二个字符串中出现的元素保存在一个数组中,遍历第一个数组,保存在第二个数组中未出现的元素,最后输出答案
解题思路
class solution : ' ' @ paramstr : thefirststringgiven @ param sub : thegivensecondstring @ return : returnsthedeleted yded sub ) : tmp=[0] * 256 # 256 as呼叫循环计算机可存储forcinsub:tmp[ord(c ) ]=1ans='forcinstr3360