![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
recursive
feeeeeeet
这个作者很懒,什么都没留下…
展开
-
Leetcode 24. Swap Nodes in Pairs
2 solutions - use two extra pointers & recursive Solution 1 use two extra pointers class Solution { public ListNode swapPairs(ListNode head) { ListNode res=new ListNode(-1); re...原创 2018-11-15 06:17:42 · 180 阅读 · 0 评论 -
Leetcode 45&55. Jump Game I &II
There are many solutions for these two problems. For Jump Game I, greedy is the best method, but we can also use DP to solve it. Jump Game I Solution 1 DP There are two kind of DP solution, bottom-up...原创 2018-12-13 01:02:27 · 126 阅读 · 0 评论 -
Leetcode 70. Climbing Stairs
recursion & dp(Fibonacci Number) Recursion !TLE class Solution: def climbStairs(self, n): """ :type n: int :rtype: int """ if n == 1: retur...原创 2018-12-28 23:43:58 · 82 阅读 · 0 评论 -
Leetcode 77. Combinations
recursion &dfs recursion(slow) class Solution: def combine(self, n, k): """ :type n: int :type k: int :rtype: List[List[int]] """ res = [] ...原创 2018-12-29 06:52:33 · 132 阅读 · 0 评论 -
Leetcode 82&83. Remove Duplicates from Sorted List I & II
recursion can be used in II difference between pre=cur(the same node) and pre.val=cur.val (two nodes have the same number) Remove Duplicates from Sorted List I 2 solutions slow version # Definition fo...原创 2018-12-31 00:24:20 · 112 阅读 · 0 评论 -
Leetcode 89. Gray Code
2 solutions class Solution: def grayCode(self, n): """ :type n: int :rtype: List[int] """ return map(lambda x:int(x,2),self.gray(n)) def gray(self,n): ...原创 2018-12-31 19:36:00 · 103 阅读 · 0 评论 -
Leetcode 99. Recover Binary Search Tree
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def recoverTree(s...原创 2019-01-07 03:31:36 · 120 阅读 · 0 评论 -
Leetcode 100 & 101. Same Tree & Symmetric Tree
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def isSameTree(se...原创 2019-01-07 03:33:12 · 94 阅读 · 0 评论 -
Leetcode 104 & 111. Minimum & Maximum Depth of Binary Tree
Maximum Depth of Binary Tree # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class So...原创 2019-01-07 07:27:14 · 87 阅读 · 0 评论