
菜
33.Search in Rotated Sorted Array
用二分查找
1 |
def search(self, nums, target): |
35.Search Insert Position
因为是sorted所以用二分查找
1 |
class Solution(object): |
其实刚开始想到的是一个很慢的方法->
1 |
nums.append(target) |
39.Combination Sum
dfs
1 |
res = [] |
53.Maximum Subarray
1 |
cur = maxs = -float('inf') |
538.Convert BST to Greater Tree
1 |
a = 0 |
860.Lemonade Change
1 |
five, ten = 0, 0 |
100.Same Tree
1 |
if p == None and q == None: |
594.Longest Harmonious Subsequence
1 |
def findLHS(self, nums): |
671.Second Minimum Node In a Binary Tree
1 |
def findSecondMinimumValue(self, root): |
152.Maximum Product Subarray
普通方法
1 |
max1 = big = small = nums[0] |
在讨论里看到的奇妙方法
1 |
def maxProduct(self, A): |
942.DI String Match
1 |
def diStringMatch(self, S): |




近期评论