字典树 336. 回文对 PYTHON
利用逆置原有元素找搭配 中间元素如果是回文元素,同时元素左边和右边互为逆置这样的字符串必定为回文,就是利用了这个原理进行 class Solution(object): def palindromePairs(self, words): :type words: List[str] :rtype: List[List[int]] # 本身就是回文串单词 palidStr = [] # 翻转单词记录位置 rev_words = {} # 结果
下载地址
用户评论