![](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 & recursiveSolution 1 use two extra pointersclass Solution { public ListNode swapPairs(ListNode head) { ListNode res=new ListNode(-1); re...原创 2018-11-15 06:17:42 · 173 阅读 · 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 ISolution 1 DPThere are two kind of DP solution, bottom-up...原创 2018-12-13 01:02:27 · 119 阅读 · 0 评论 -
Leetcode 70. Climbing Stairs
recursion & dp(Fibonacci Number)Recursion!TLEclass Solution: def climbStairs(self, n): """ :type n: int :rtype: int """ if n == 1: retur...原创 2018-12-28 23:43:58 · 79 阅读 · 0 评论 -
Leetcode 77. Combinations
recursion &dfsrecursion(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 · 131 阅读 · 0 评论 -
Leetcode 82&83. Remove Duplicates from Sorted List I & II
recursion can be used in IIdifference between pre=cur(the same node) and pre.val=cur.val (two nodes have the same number)Remove Duplicates from Sorted List I2 solutionsslow version# Definition fo...原创 2018-12-31 00:24:20 · 111 阅读 · 0 评论 -
Leetcode 89. Gray Code
2 solutionsclass 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 · 100 阅读 · 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 = Noneclass Solution: def recoverTree(s...原创 2019-01-07 03:31:36 · 118 阅读 · 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 = Noneclass Solution: def isSameTree(se...原创 2019-01-07 03:33:12 · 92 阅读 · 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 = Noneclass So...原创 2019-01-07 07:27:14 · 86 阅读 · 0 评论