![](https://img-blog.csdnimg.cn/20190918140158853.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
leetcode
leetcode
荷西·H
你不知道这份散发臭味的代码经历了多少次需求变更。
展开
-
leetcode Tree 遍历基础整理 144& 94 & 145 &102
依次分别是二叉树的前序、中序、后序、层次遍历,除了层次遍历都有明确要求用循环而非递归做 144.前序遍历 直接给大家看discussion部分的优美代码吧,自己的就不拿出来丢人了… class Solution(object): def preorderTraversal(self, root): ret = [] stack = [root] ...原创 2019-03-01 09:59:18 · 169 阅读 · 0 评论 -
leetcode206 Reverse Linked List
描述:链表反转 e.g. input: 1->2->3->4->5->null output:5->4->3->2->1->null # Definition for singly-linked list. # class ListNode: # def __init__(self原创 2019-02-25 23:50:20 · 112 阅读 · 0 评论 -
leetcode328:Odd Even Linked List
自己的丑陋代码 # easy ''' # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None ''' class Solution(object): L=None def ...原创 2019-02-25 23:53:56 · 127 阅读 · 0 评论 -
leetcode141. Linked List Cycle
这篇说得挺好的 https://blog.csdn.net/liuchonge/article/details/73520414原创 2019-02-20 21:13:51 · 121 阅读 · 0 评论 -
leetcode Tree 101 Symmetric Tree
遍历的做法 def isSymmetric(self, root: TreeNode) -> bool: ls,rs=[],[] if not root: return True ls.append(root.left) rs.append(root.right) while ls and rs...原创 2019-03-03 13:34:13 · 104 阅读 · 0 评论 -
dp问题的分析思路 | leetcode 337 Tree 子树和孙子树:)
分解步骤的分析写得很好 , 是一个dp问题通常的想法 https://leetcode.com/problems/house-robber-iii/discuss/79330/Step-by-step-tackling-of-the-problem原创 2019-03-06 14:15:01 · 224 阅读 · 0 评论