# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param Words string字符串一维数组 # @return string字符串 # class Solution: def WordsMerge(self , Words ): # write code here def mergetwo(w1, w2): stack = list(w1) n = len(w2) for i in range(n): if w2[i] == stack[-1]: stack.pop() tmp = w2[i+1:] else: tmp = w2[i:] break res = "".join(stack) + tmp return res if not Words: return "" w1 = Words[0] for i in range(1, len(Words)): w1 = mergetwo(w1, Words[i]) return w1