leetcode--删除字符
删除字符
1.问题描述
输入两个字符串s和t,判断s是否在删除一些字符后得到t
2.问题示例
输入s = 'abc'、t = 'c',输出True
def del_chrs(str1, str2): i, j = 0, 0 i_total = len(str1) j_total = len(str2) while j<j_total and i < i_total: if str1[i]==str2[j]: i += 1 j += 1 else: i += 1 if j>=j_total: print('{0} in {1}'.format(str2, str1)) else: print('{0} not in {1}'.format(str2, str1)) del_chrs('abc', 'c')

浙公网安备 33010602011771号