随笔分类 -  leetcode

leetcode刷题记录
摘要:不是我自己做出来的 class Solution(object): def generateTrees(self,n): Listn = [i for i in range(1, n+1)] def gt(List): res = [] if not List: return [None] if l 阅读全文
posted @ 2019-11-13 16:42 欣姐姐 阅读(128) 评论(0) 推荐(0)
摘要:class Solution(object): def isSymmetric(self, root): """ :type root: TreeNode :rtype: bool """ if not root:return True def Tree(p,q): if not p and not 阅读全文
posted @ 2019-11-10 18:05 欣姐姐 阅读(309) 评论(0) 推荐(0)
摘要:超出时间了。。。 class Solution(object): def countRangeSum(self, nums, lower, upper): """ :type nums: List[int] :type lower: int :type upper: int :rtype: int 阅读全文
posted @ 2019-11-10 17:49 欣姐姐 阅读(432) 评论(0) 推荐(0)
摘要:也不是我做出来的,, class Solution(object): def isValidBST(self, root): """ :type root: TreeNode :rtype: bool """ res=[] def helper(root): if not root: return 阅读全文
posted @ 2019-11-07 10:54 欣姐姐 阅读(146) 评论(0) 推荐(0)
摘要:这不是我写的,对于树的学习处于初始阶段。 class Solution(object): def inorderTraversal(self, root): """ :type root: TreeNode :rtype: List[int] """ white,gray=0,1 res=[] st 阅读全文
posted @ 2019-11-07 10:38 欣姐姐 阅读(165) 评论(0) 推荐(0)
摘要:class Solution(object): def removeKdigits(self, num, k): """ :type num: str :type k: int :rtype: str """ if k>=len(num): return '0' i=0 j=1 while k an 阅读全文
posted @ 2019-11-05 10:03 欣姐姐 阅读(294) 评论(0) 推荐(0)
摘要:这道题也不是我自己做出来的,只能说大佬牛逼!!! class Solution(object): def decodeString(self, s): """ :type s: str :rtype: str """ stack, res, multi = [], "", 0 for c in s: 阅读全文
posted @ 2019-11-04 18:04 欣姐姐 阅读(167) 评论(0) 推荐(0)
摘要:这个也不是我自己做出来的,感觉我还打不到这个水平,我好菜! class Solution: def maximalRectangle(self, matrix) -> int: if not matrix or not matrix[0]: return 0 row = len(matrix) co 阅读全文
posted @ 2019-11-04 15:23 欣姐姐 阅读(186) 评论(0) 推荐(0)
摘要:class Solution(object): def largestRectangleArea(self, heights): """ :type heights: List[int] :rtype: int """ stack = [] heights = [0] + heights + [0] 阅读全文
posted @ 2019-11-04 11:23 欣姐姐 阅读(258) 评论(0) 推荐(0)
摘要:class Solution(object): def simplifyPath(self, path): """ :type path: str :rtype: str """ stack=[] path=path.split('/') for item in path: if item=='.. 阅读全文
posted @ 2019-11-02 13:38 欣姐姐 阅读(157) 评论(0) 推荐(0)
摘要:# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def 阅读全文
posted @ 2019-11-01 15:12 欣姐姐 阅读(117) 评论(0) 推荐(0)
摘要:用栈做: # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): 阅读全文
posted @ 2019-10-31 22:07 欣姐姐 阅读(98) 评论(0) 推荐(0)
摘要:# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def 阅读全文
posted @ 2019-10-31 20:29 欣姐姐 阅读(121) 评论(0) 推荐(0)
摘要:慢慢找到对链表的感觉,加油保持前进呀哈哈哈哈!!!! # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None c 阅读全文
posted @ 2019-10-26 21:18 欣姐姐 阅读(215) 评论(0) 推荐(0)
摘要:class Solution(object): def rotateRight(self, head, k): """ :type head: ListNode :type k: int :rtype: ListNode """ if not head: return if head.next==N 阅读全文
posted @ 2019-10-25 10:28 欣姐姐 阅读(182) 评论(0) 推荐(0)
摘要:借助新增加的结点 class Solution(object): def swapPairs(self, head): """ :type head: ListNode :rtype: ListNode """ if not head: return if head.next==None: retu 阅读全文
posted @ 2019-10-25 10:04 欣姐姐 阅读(170) 评论(0) 推荐(0)
摘要:class Solution: def countAndSay(self, n: int) -> str: r={} r[1]='1' r[2]='11' r[3]='21' r[4]='1211' r[5]='111221' if n in r: return r[n] else: i=6 whi 阅读全文
posted @ 2019-10-24 19:31 欣姐姐 阅读(154) 评论(0) 推荐(0)
摘要:用列表完成!!!! # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def remove 阅读全文
posted @ 2019-10-23 22:44 欣姐姐 阅读(130) 评论(0) 推荐(0)
摘要:# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def mergeTwoLists(se 阅读全文
posted @ 2019-10-23 19:37 欣姐姐 阅读(179) 评论(0) 推荐(0)
摘要:第一次解除到链表相关的题目,不会做,看了别人答案。 # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solu 阅读全文
posted @ 2019-10-23 16:55 欣姐姐 阅读(157) 评论(0) 推荐(0)