07 2018 档案
摘要:法1(python):利用helper function遍历数组中每一个元素直到找到相对应的最长回文串 时间复杂度O(n^2), 空间复杂度O(n) 方法2: dp方法,找到回文规律是,要不然元素个数为2,要不然是真回文,如果是真回文,那它的子集也应该是真回文 时间复杂度:O(n^2), 空间复杂度
阅读全文
摘要:It is a interesting question to consider the two arrays as one group. As mentioned in the question, we always use binary search to decrease the time c
阅读全文
摘要:这是一道很好的题,注意用数组去记录有意义的值,在这里,因为我们只希望字母重复出现一次,所以我们其实只需要知道字母最后出现的位置即可,所有字母最后出现的位置或最开始的位置都可以是最长子串的开始,我们只需要一个数组去记录当前字母的最后出现位置,很巧妙,要学会抓问题的关键。 时间复杂度:O(n) 空间复杂
阅读全文
摘要:# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # time: O(1), space: O(1) def addTwoNumb...
阅读全文
摘要:方法1: 时间复杂度: O(n) 空间复杂度:O(n)
阅读全文

浙公网安备 33010602011771号