Umm... I feel there is another good solution🤔
Solution using Python3
def solve(s, word): ret = [] if word == '': ret.append(''.rjust(len(s), '-')) return ret left_s = '' for si in range(len(s)): if word[0] == s[si]: left_s = ''.rjust(si, '-') + s[si] if s[si+1:] == '' and word[1:] == '': ret.append(left_s) else: right_s_list = solve(s[si+1:], word[1:]) for right_s in right_s_list: ret.append(left_s + right_s) return ret if __name__ == '__main__': for s in solve('bbananana', 'banana'): print(s)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Umm... I feel there is another good solution🤔
Solution using Python3