![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetCode刷题
mejife
这个作者很懒,什么都没留下…
展开
-
0104.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 Solution: def maxDepth(self, root: TreeNode) -> int: def MaxDepth(root).原创 2020-07-18 17:39:42 · 82 阅读 · 0 评论 -
0088.merge-sorted-array
from typing import List#--------testcase input---------l1a = [1,2,3,0,0,0]l1b = [2,5,6]#----------------------------main function--------------------------------# V1.0 要求原地修改,从后往前比较,并从后往前插入# def merge(nums1: List[int], m: int, nums2: List[int], n:.原创 2020-07-03 11:22:05 · 99 阅读 · 0 评论 -
0053.maximum-sum-subarray
from typing import Listimport sys#--------testcase input---------nums1 = [-2,1,-3,4,-1,2,1,-5,4]nums2 = [1]nums3 = [-2,1]nums4 = [-1,-2]nums5 = [-1,-2,-3,-4,-5,-6,-7]nums6 = [-1,-2,-3,1,-5,-6,-7]#----------------------------main function-------.原创 2020-07-02 09:39:07 · 139 阅读 · 0 评论 -
0026.remove-duplicates-from-sorted-array
from typing import Listimport operator#notice:#--------input---------nums1 = [0,0,1,1,1,2,2,3,3,4]nums2 = [1]nums3 = [1,1]nums4 = [1,2]nums5 = [1,1,2,3]#----------------------------success--------------------------------#时间复杂度 O() #空间复杂度 O(1).原创 2020-06-20 11:22:21 · 95 阅读 · 0 评论 -
0021.MergeTwoSortedLists
#----------------------------class init--------------------------------class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = nextclass LinkList(object): def __init__(self): self.head ..原创 2020-06-19 16:04:10 · 156 阅读 · 0 评论 -
0001.twoSum
from typing import List#--------暴力枚举---------#时间复杂度 O(N^2)#空间复杂度 O(1)# class Solution():# def __init__(self, nums: List[int], target: int) -> List[int]: # 关于为什要用__init__,可参考https://blog.csdn.net/geerniya/article/details/77487941# se.原创 2020-06-18 15:21:46 · 73 阅读 · 0 评论 -
0020.ValidParentheses
from typing import List#--------input---------s = ['{[([])]}']s1 = '[)'s2 = '()'s3 = ']'#----------------------------fail--------------------------------#--fail1:[)不能过...# def isVld(s: str) -> bool:# ram = []# for x in s:# .原创 2020-06-18 15:17:35 · 90 阅读 · 0 评论