任务:
Write a recursive function named is_subsequence that takes two string parameters and returns True if the first string is a subsequence of the second string, but returns False otherwise. We say that string A is a subsequence of string B if you can derive A by deleting zero or more letters from B without changing the order of the remaining letters. You can assume that neither string contains upper-case letters.
You may use default arguments and/or helper functions.
Your recursive function must not: use imports. use any loops use any variables declared outside of the function. use any mutable default arguments.
到目前为止我拥有的内容(必须使用此格式):
def is_subsequence(strA, strB = None):
if strB == None:
strB = []
print(is_subsequence("dog", "dodger"))
我的问题:
我不知道如何通过删除字母来递归地编辑字符串。(strB.replace("e","")
不起作用)
我不知道根据说明是否允许这样做,但我添加了一个索引参数,并能够得出这个结论。(代码片段是Python)