写一个类,输入一个字符串和一个列表,列表包含了部分字符串字母可能的排练组合,输出包含部分中最长的组合,例如
print(longest_word_sequence("Green", {"Gn", "Gren", "Grean", "en"}))
print(longest_word_sequence("pythonexercises", {"py", "ex", "exercises","axercises"})) #输入
Gren
exercises #输出
字符串的排列组合还需要考虑参与排列的字母,例如apple的排列: "a", "ap", "al", "ae", "app", "apl", "ape", "ale", "appl", "appe", "aple", "apple", "p", "pp", "pl", "pe", "ppl", "ppe", "ple", "pple", "l", "le", "e", "".
我在编写的时候不知道如何实现不同字母参与的排列,比如abc,我不是很懂如何能实现,a,ab,ac这样,只能写出abc,cba等。希望能得到解答,谢谢!