数据艺术家

数据挖掘领域懵逼者
私信 关注
长行
码龄4年
  • 194,000
    被访问量
  • 1,900
    原创文章
  • 2,187
    作者排名
  • 120
    粉丝数量
  • 于 2017-04-16 加入CSDN
获得成就
  • 获得70次点赞
  • 内容获得114次评论
  • 获得219次收藏
荣誉勋章
兴趣领域
  • #人工智能
    #机器学习#数据分析#Python#自然语言处理
TA的专栏
  • 机器学习
    4篇
  • LeetCode题解
    1711篇
  • ECharts示例图
    1篇
  • LeetCode刷题顺序
    4篇
  • 数据结构与算法专项
    11篇
  • Python报错排坑
    15篇
  • 诗词格律详解
    48篇
  • Python数据挖掘教程
    22篇
  • Github项目推荐
    10篇
  • 统计学笔记
    13篇
  • 统计学的Python实现
    20篇
  • 学习NLP的第N天
    24篇
  • 最近
  • 文章
  • 资源
  • 问答
  • 课程
  • 帖子
  • 收藏
  • 关注/订阅

004:感知机(2):感知机学习策略

之前已经得到了感知机模型f(x)=sign(w⋅x+b)f(x)=sign(w·x+b)f(x)=sign(w⋅x+b)及其假设空间F={f∣Y=fw,b(X),w∈Rn,b∈R}\mathcal{F} = \{f|Y=f_{w,b}(X),w \in R^n,b \in R\}F={f∣Y=fw,b​(X),w∈Rn,b∈R},完成了统计学习方法的第一个要素:模型。下面考虑按照要按照什么样的准则从假设空间中选取最优模型,即统计学习方法的第二个要素:策略。即当训练数据集线性可分时,如何找出可以将正实例点和
原创
7阅读
0评论
0点赞
发布博客于 8 天前

003:点到超平面距离公式的推导过程

【例2】已知SSS为维n欧式空间中的n-1维超平面S : w⋅x+b=0S \ : \ \bold{w}·x + b =0S : w⋅x+b=0其中 w\bold{w}w 和 xxx 均为n维向量。n维空间中的点 x0=(x0(1),x0(2),⋯ ,x0(n))x_0 = (x_0^{(1)},x_0^{(2)},\cdots,x_0^{(n)})x0​=(x0(1)​,x0(2)​,⋯,x0(n)​) 。求证:点 PPP 到超平面 SSS 的距离 d.
原创
10阅读
0评论
0点赞
发布博客于 8 天前

002:常见范数的定义和性质

范数 ,对应闵可夫斯基距离 (Minkowski distance) ,其定义如下:【定义2】Lp范数假设n维向量x=(x1,x2,⋯ ,xn)Tx = (x_1,x_2,\cdots,x_n)^Tx=(x1​,x2​,⋯,xn​)T,其Lp范数记作∣∣x∣∣p||x||_p∣∣x∣∣p​,定义为∣∣x∣∣p=(∣x1∣p+∣x2∣p+⋯+∣xn∣p)1p||x||_p = (|x_1|^p+|x_2|^p+\cdots+|x_n|^p)^{\frac{1}{p}}∣∣x∣∣p​=(∣x1​∣p
原创
6阅读
0评论
0点赞
发布博客于 8 天前

001:感知机(1):图解感知机模型

首先,我们来看下面的例子。【例1】通过给定的身高、体重组合与对应性别的数据,实现对未知身高、体重组合的性别预测。在这个例子中,输入空间为所有可能的身高、体重组合(二维特征向量),记作 X⊆R2\mathcal{X} \subseteq R^2X⊆R2 ;输出空间为所有可能的性别(只有两个取值的离散变量),记作Y⊆{+1,−1}\mathcal{Y} \subseteq \{+1,-1\}Y⊆{+1,−1}。输入实例xxx的特征向量记作x=(x(1),x(2))T∈Xx = (x^{(1)},x^{(2
原创
7阅读
0评论
0点赞
发布博客于 8 天前

ECharts示例图001:二维感知机示例图(2维/散点+折线图)

【示例图】【实现代码】option = { grid: { left: '3%', right: '7%', bottom: '7%', containLabel: true }, tooltip: { // trigger: 'axis', showDelay: 0, formatter: function (params) { if (pa
原创
6阅读
0评论
0点赞
发布博客于 9 天前

Latex公式符号速查表(第1版)

文章目录基础数学单字符符号多字符符号xy\frac{x}{y}yx​ 分式exe^xex 上下标xy\sqrt[y]{x}yx​ 根式∫ab\int_{a}^{b}∫ab​ 积分∑i=1n\sum^n_{i=1}∑i=1n​ 大型运算符括号括号种类括号列表标注符号集合符号空格符号箭头符号长箭头单字符箭头省略号符号和希腊字母 (大写&小写)特殊符号希腊字母样式符号多行模式发布时间:2021.03.27基础数学单字符符号符号名称符号显示符号代码无穷大∞\infty∞
原创
37阅读
0评论
1点赞
发布博客于 14 天前

LeetCode题解(0948):令牌放置(Python)

题目:原题链接(中等)标签:贪心算法、排序、双指针解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN)O(NlogN)O(NlogN)O(N)O(N)O(N)48ms (57.23%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def bagOfTokensScore(self, tokens: List[int], power: int) -> int
原创
28阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0945):使数组唯一的最小增量(Python)

题目:原题链接(中等)标签:数组、排序解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN)O(NlogN)O(NlogN)O(N)O(N)O(N)320ms (98.61%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minIncrementForUnique(self, A: List[int]) -> int: count =
原创
22阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0934):最短的桥(Python)

题目:原题链接(中等)标签:广度优先搜索、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N2)O(N^2)O(N2)324ms (16.72%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def shortestBridge(self, A: List[List[int]]) -> int: m =
原创
24阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0932):漂亮数组(Python)

题目:原题链接(中等)标签:分治算法、递归解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN)O(NlogN)O(NlogN)O(N)O(N)O(N)52ms (30.77%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def beautifulArray(self, N: int) -> List[int]: if N <= 2:
原创
14阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0931):下降路径最小和(Python)

题目:原题链接(中等)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N2)O(N^2)O(N2)68ms (56.74%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: _BIG = 10001 def minFallingPathSum(self, A: List[List[int]]) -> int:
原创
10阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0926):将字符串翻转到单调递增(Python)

题目:原题链接(中等)标签:数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)92ms (41.28%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minFlipsMonoIncr(self, S: str) -> int: lst1 = [0] for ch in S:
原创
11阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0923):三数之和的多种可能(Python)

题目:原题链接(中等)标签:数组、双指针解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(logN)O(logN)O(logN)4404ms (5.19%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: _MOD = 10 ** 9 + 7 def threeSumMulti(self, A: List[int], target:
原创
23阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0918):环形子数组的最大和(Python)

题目:原题链接(中等)标签:数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)228ms (58.44%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def maxSubarraySumCircular(self, A: List[int]) -> int: ans1 = cur1 = 0
原创
44阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0915):分割数组(Python)

题目:原题链接(中等)标签:数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)212ms (75.44%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def partitionDisjoint(self, A: List[int]) -> int: lst1 = [] lst2 = [
原创
16阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0912):排序数组(Python)

题目:原题链接(中等)标签:排序解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN)O(NlogN)O(NlogN)O(logN)O(logN)O(logN)52ms (97.02%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def sortArray(self, nums: List[int]) -> List[int]: nums.
原创
26阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0911):在线选举(Python)

题目:原题链接(中等)标签:二分查找解法时间复杂度空间复杂度执行用时Ans 1 (Python)构造 = O(N)O(N)O(N) ; 查询 = O(logN)O(logN)O(logN)O(N)O(N)O(N)740ms (64.29%)Ans 2 (Python)Ans 3 (Python)解法一:class TopVotedCandidate: def __init__(self, persons: List[int], ti
原创
23阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0910):最小差值II(Python)

题目:原题链接(中等)标签:贪心算法、数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN)O(NlogN)O(NlogN)O(logN)O(logN)O(logN)196ms (27.84%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def smallestRangeII(self, A: List[int], K: int) -> int:
原创
14阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0909):蛇梯棋(Python)

题目:原题链接(中等)标签:广度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)108ms (100.00%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def snakesAndLadders(self, board: List[List[int]]) -> int: m, n = len(b
原创
35阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0904):水果成篮(Python)

题目:原题链接(中等)标签:数组、双指针、滑动窗口解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)1160ms (17.70%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def totalFruit(self, tree: List[int]) -> int: ans = 0 l,
原创
12阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0900):RLE迭代器(Python)

题目:原题链接(中等)标签:数组、设计解法时间复杂度空间复杂度执行用时Ans 1 (Python)RLEIterator = O(A)O(A)O(A) ; next = O(N)O(N)O(N)O(A)O(A)O(A)48ms (55.38%)Ans 2 (Python)Ans 3 (Python)解法一:class RLEIterator: def __init__(self, A: List[int]): sel
原创
17阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0898):子数组按位或操作(Python)

题目:原题链接(中等)标签:位运算、动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN)O(NlogN)O(NlogN)O(NlogN)O(NlogN)O(NlogN)752ms (69.35%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def subarrayBitwiseORs(self, A: List[int]) -> int:
原创
40阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0886):可能的二分法(Python)

题目:原题链接(中等)标签:图、深度优先搜索、广度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)152ms (75.80%)Ans 2 (Python)Ans 3 (Python)解法一:def build_graph(edges): graph = collections.defaultdict(set) for edge in edges:
原创
15阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0885):螺旋矩阵III(Python)

题目:原题链接(中等)标签:数组、数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(R×C)O(R×C)O(R×C)O(1)O(1)O(1)116ms (80.00%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def spiralMatrixIII(self, R: int, C: int, r0: int, c0: int) -> List[List[in
原创
14阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0881):救生艇(Python)

题目:原题链接(中等)标签:贪心算法、双指针、数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN)O(NlogN)O(NlogN)O(logN)O(logN)O(logN)108ms (100.00%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def numRescueBoats(self, people: List[int], limit: int)
原创
19阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0875):爱吃香蕉的珂珂(Python)

题目:原题链接(中等)标签:二分查找解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogM)O(NlogM)O(NlogM)O(1)O(1)O(1)552ms (12.77%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minEatingSpeed(self, piles: List[int], H: int) -> int: lef
原创
16阅读
0评论
0点赞
发布博客于 2 月前

LeetCode题解(0873):最长的斐波那契子序列的长度(Python)

题目:原题链接(中等)标签:数组、动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N3logN)O(N^3logN)O(N3logN)O(1)O(1)O(1)816ms (38.41%)Ans 2 (Python)Ans 3 (Python)解法一(暴力):class Solution: def lenLongestFibSubseq(self, A: List[int]) -> int:
原创
16阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0870):优势洗牌(Python)

题目:原题链接(中等)标签:数组、贪心算法、排序解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN)O(NlogN)O(NlogN)O(N)O(N)O(N)384ms (84.62%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def advantageCount(self, A: List[int], B: List[int]) -> List[int
原创
15阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0869):重新排序得到2的幂(Python)

题目:原题链接(中等)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(logN)O(logN)O(logN)O(logN)O(logN)O(logN)40ms (79.39%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: _BIG = 10 ** 9 def reorderedPowerOf2(self, N: int) -> bool:
原创
10阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0866):回文素数(Python)

题目:原题链接(中等)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)204ms (65.71%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: _CHANGE = { "2": 3, "4": 7, "5": 7, "6": 7, "8"
原创
21阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0858):镜面反射(Python)

题目:原题链接(中等)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(logN)O(logN)O(logN)O(1)O(1)O(1)40ms (49.40%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def mirrorReflection(self, p: int, q: int) -> int: g = math.gcd(p, q
原创
16阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0855):考场就座(Python)

题目:原题链接(中等)标签:有序映射解法时间复杂度空间复杂度执行用时Ans 1 (Python)seat = O(N)O(N)O(N) ; leave = O(N)O(N)O(N)O(N)O(N)O(N)280ms (72.41%)Ans 2 (Python)Ans 3 (Python)解法一:class ExamRoom: def __init__(self, n: int): self.n = n
原创
17阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0853):车队(Python)

题目:原题链接(中等)标签:排序、数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN)O(NlogN)O(NlogN)O(N)O(N)O(N)192ms (84.97%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def carFleet(self, target: int, position: List[int], speed: List[int]) -
原创
13阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0851):喧闹和富有(Python)

题目:原题链接(中等)标签:图、拓扑排序、广度优先搜索、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)484ms (93.42%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def loudAndRich(self, richer: List[List[int]], quiet: List[int]) ->
原创
13阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(1296):划分数组为连续数字的集合(Python)

题目:原题链接(中等)标签:数组、贪心算法、有序映射解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)124ms (100.00%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def isPossibleDivide(self, nums: List[int], k: int) -> bool: size
原创
23阅读
1评论
0点赞
发布博客于 3 月前

LeetCode题解(0846):一手顺子(Python)

题目:原题链接(中等)标签:有序映射解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)76ms (96.30%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def isNStraightHand(self, hand: List[int], W: int) -> bool: size = len(hand
原创
13阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0841):钥匙和房间(Python)

题目:原题链接(中等)标签:图、广度优先搜索、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)76ms (77.25%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def canVisitAllRooms(self, rooms: List[List[int]]) -> bool: visi
原创
13阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0838):推多米诺(Python)

题目:原题链接(中等)标签:动态规划、双指针解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)192ms (37.89%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def pushDominoes(self, dominoes: str) -> str: dominoes = list(dominoes
原创
20阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0837):新21点(Python)

题目:原题链接(中等)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(min(K+W,N))O(min(K+W,N))O(min(K+W,N))O(K+W)O(K+W)O(K+W)92ms (58.26%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def new21Game(self, N: int, K: int, W: int) -> flo
原创
13阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0835):图像重叠(Python)

题目:原题链接(中等)标签:数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N4)O(N^4)O(N4)O(1)O(1)O(1)2312ms (14.12%)Ans 2 (Python)Ans 3 (Python)解法一(极致暴力):class Solution: def largestOverlap(self, img1: List[List[int]], img2: List[List[int]]) ->
原创
14阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0826):安排工作以达到最大收益(Python)

题目:原题链接(中等)标签:二分查找、双指针解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN+WlogN)O(NlogN+WlogN)O(NlogN+WlogN)O(N)O(N)O(N)388ms (87.74%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def maxProfitAssignment(self, difficulty: List[int]
原创
40阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0825):适龄的朋友(Python)

题目:原题链接(中等)标签:数组、哈希表解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(1212+N)O(121^2+N)O(1212+N)O(121)O(121)O(121)200ms (41.03%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def numFriendRequests(self, ages: List[int]) -> int:
原创
11阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0823):带因子的二叉树(Python)

题目:原题链接(中等)标签:动态规划、树解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N)O(N)O(N)524ms (35.00%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: _MOD = 10 ** 9 + 7 def numFactoredBinaryTrees(self, A: List[int]) -> in
原创
10阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0822):翻转卡片游戏(Python)

题目:原题链接(中等)标签:哈希表解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)140ms (24.62%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def flipgame(self, fronts: List[int], backs: List[int]) -> int: same = {fro
原创
20阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0820):单词的压缩编码(Python)

题目:原题链接(中等)标签:字典树、哈希表解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(W×L+WlogW)O(W×L+WlogW)O(W×L+WlogW)O(W×L)O(W×L)O(W×L)96ms (86.49%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minimumLengthEncoding(self, words: List[str]) -&g
原创
17阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0807):保持城市天际线(Python)

题目:原题链接(中等)标签:数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(M×N)O(M×N)O(M×N)O(M×N)O(M×N)O(M×N)76ms (93.28%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int:
原创
17阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0813):最大平均值和的分组(Python)

题目:原题链接(中等)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(K×N2)O(K×N^2)O(K×N2)O(N)O(N)O(N)464ms (36.18%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def largestSumOfAverages(self, A: List[int], K: int) -> float: #
原创
26阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0808):分汤(Python)

题目:原题链接(中等)标签:动态规划、记忆化递归解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(min(N,2002))=O(1)O(min(N,200^2))=O(1)O(min(N,2002))=O(1)O(min(N,2002))O(min(N,200^2))O(min(N,2002))=O(1)36ms (98.92%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution:
原创
17阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0802):找到最终的安全状态(Python)

题目:原题链接(中等)标签:图、拓扑排序、广度优先搜索、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N+E)O(N+E)O(N+E)O(N+E)O(N+E)O(N+E)180ms (53.74%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def eventualSafeNodes(self, graph1: List[List[int]]) ->
原创
19阅读
1评论
0点赞
发布博客于 3 月前

LeetCode题解(0801):使序列递增的最小交换次数(Python)

题目:原题链接(中等)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)112ms ()Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minSwap(self, A: List[int], B: List[int]) -> int: size = len(A) dp =
原创
22阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0799):香槟塔(Python)

题目:原题链接(中等)标签:动态规划、记忆化递归解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N2)O(N^2)O(N2)144ms (32.52%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def __init__(self): self.total_poured = 0 def champagneTow
原创
16阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0797):所有可能的路径(Python)

题目:原题链接(中等)标签:回溯算法、图、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N!)O(N!)O(N!)O(N!)O(N!)O(N!)47ms (85.53%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def allPathsSourceTarget(self, graph: List[List[int]]) -> List[List[
原创
22阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0795):区间子数组个数(Python)

题目:原题链接(中等)标签:数组、双指针、滑动窗口解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)324ms (99.45%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def numSubarrayBoundedMax(self, A: List[int], L: int, R: int) -> int:
原创
19阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0792):匹配子序列的单词数(Python)

题目:原题链接(中等)标签:数组、哈希表解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(S+W×L)O(S+W×L)O(S+W×L)O(26×S)O(26×S)O(26×S)1020ms (22.45%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def numMatchingSubseq(self, S: str, words: List[str]) -> i
原创
16阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0790):多米诺和托米诺平铺(Python)

题目:原题链接(中等)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)40ms (83.33%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: _MOD = 10 ** 9 + 7 def numTilings(self, n: int) -> int: now = [1, 0, 0
原创
13阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0789):逃脱阻碍者(Python)

题目:原题链接(中等)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(G)O(G)O(G)O(1)O(1)O(1)32ms (95.45%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def escapeGhosts(self, ghosts: List[List[int]], target: List[int]) -> bool: d
原创
20阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0785):判断二分图(Python)

题目:原题链接(中等)标签:图、广度优先搜索、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)44ms (85.10%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def isBipartite(self, graph: List[List[int]]) -> bool: size = le
原创
19阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0775):全局倒置与局部倒置(Python)

题目:原题链接(中等)标签:数组、数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)372ms (81.98%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def isIdealPermutation(self, A: List[int]) -> bool: n1 = 0 # 局部倒置
原创
13阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0768):最多能完成排序的块II(Python)

题目:原题链接(困难)标签:数组、排序解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN)O(NlogN)O(NlogN)O(N)O(N)O(N)100ms (37.20%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def maxChunksToSorted(self, arr1: List[int]) -> int: arr2 = l
原创
21阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0769):最多能完成排序的块(Python)

题目:原题链接(中等)标签:数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N)O(N)O(N)36ms (80.58%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def maxChunksToSorted(self, arr1: List[int]) -> int: ans = 0 find
原创
16阅读
1评论
0点赞
发布博客于 3 月前

LeetCode题解(0764):最大加号标志(Python)

题目:原题链接(中等)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2+M)O(N^2+M)O(N2+M)O(N2)O(N^2)O(N2)4016ms (22.22%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def orderOfLargestPlusSign(self, N: int, mines: List[List[int]]) ->
原创
18阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0756):金字塔转换矩阵(Python)

题目:原题链接(中等)标签:深度优先搜索、位运算解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(7N)O(7^N)O(7N)O(N2)O(N^2)O(N2)56ms (14.49%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def pyramidTransition(self, bottom: str, allowed: List[str]) -> bool:
原创
17阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0754):到达终点数字(Python)

题目:原题链接(中等)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(\sqrt{N})O(N​)O(1)O(1)O(1)132ms (29.20%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def reachNumber(self, target: int) -> int: # 1 : [1] # 2 : [
原创
17阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0752):打开转盘锁(Python)

题目:原题链接(中等)标签:广度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(10000)O(10000)O(10000)O(10000)O(10000)O(10000)568ms (76.79%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def openLock(self, dead_ends: List[str], target: str) ->
原创
23阅读
1评论
0点赞
发布博客于 3 月前

LeetCode题解(0740):删除与获得点数(Python)

题目:原题链接(中等)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)56ms (97.08%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def deleteAndEarn(self, nums: List[int]) -> int: if not nums: r
原创
12阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0729):我的日程安排表I(Python)

题目:原题链接(中等)标签:数组、有序映射解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N)O(N)O(N)380ms (50.66%)Ans 2 (Python)Ans 3 (Python)解法一:class Node: __slots__ = ["start", "end", "left", "right"] def __init__(self, start, end):
原创
28阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0732):我的日程安排表 III(Python)

题目:原题链接(困难)标签:数组、有序映射、线段树解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2logN)O(N^2logN)O(N2logN)O(N)O(N)O(N)1956ms (13.69%)Ans 2 (Python)Ans 3 (Python)解法一:class MyCalendarThree: def __init__(self): self.count = collections.
原创
14阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0731):我的日程安排表II(Python)

题目:原题链接(中等)标签:数组、有序映射、线段树解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N)O(N)O(N)1412ms (27.85%)Ans 2 (Python)Ans 3 (Python)解法一:class MyCalendarTwo: def __init__(self): self.lst1 = [] self.lst2 = []
原创
16阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0713):乘积小于K的子数组(Python)

题目:原题链接(中等)标签:数组、双指针、滑动窗口解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)1236ms (47.37%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def numSubarrayProductLessThanK(self, nums: List[int], k: int) -> int:
原创
19阅读
1评论
0点赞
发布博客于 3 月前

LeetCode题解(0712):两个字符串的最小ASCII删除和(Python)

题目:原题链接(中等)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N×M)O(N×M)O(N×M)O(N×M)O(N×M)O(N×M)676ms (71.56%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minimumDeleteSum(self, s1: str, s2: str) -> int: dp = [[0]
原创
16阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0695):岛屿的最大面积(Python)

题目:原题链接(中等)标签:数组、广度优先搜索、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N×M)O(N×M)O(N×M)O(N×M)O(N×M)O(N×M)168ms (36.22%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def maxAreaOfIsland(self, grid: List[List[int]]) -> int:
原创
21阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0688):“马”在棋盘上的概率(Python)

题目:原题链接(中等)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2×K)O(N^2×K)O(N2×K)O(N2)O(N^2)O(N2)168ms (73.86%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def knightProbability(self, n: int, k: int, r: int, c: int) -> float
原创
11阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0677):键值映射(Python)

题目:原题链接(中等)标签:字典树解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N×L)O(N×L)O(N×L)O(N×L)O(N×L)O(N×L)40ms (78.90%)Ans 2 (Python)Ans 3 (Python)解法一:class MapSum: def __init__(self): self.trie = [0, {}] self.count = {}
原创
14阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0673):最长递增子序列的个数(Python)

题目:原题链接(中等)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N)O(N)O(N)1112ms (49.05%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def findNumberOfLIS(self, nums: List[int]) -> int: size = len(nums)
原创
31阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0672):灯泡开关II(Python)

题目:原题链接(中等)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(1)O(1)O(1)O(1)O(1)O(1)32ms (98.70%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def flipLights(self, n: int, m: int) -> int: if n == 1: return 2
原创
13阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0670):最大交换(Python)

题目:原题链接(中等)标签:数组、数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(logN)O(logN)O(logN)O(logN)O(logN)O(logN)52ms (6.21%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def maximumSwap(self, num: int) -> int: num = [int(ch) fo
原创
17阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0667):优美的排列II(Python)

题目:原题链接(中等)标签:数组、脑筋急转弯解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)60ms (56.80%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def constructArray(self, n: int, k: int) -> List[int]: ans = [1]
原创
37阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0658):找到K个最接近的元素(Python)

题目:原题链接(中等)标签:二分查找解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(logN+K)O(logN+K)O(logN+K)O(K)O(K)O(K)76ms(45.91%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def findClosestElements(self, arr: List[int], k: int, x: int) -> List
原创
30阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0650):只有两个键的键盘(Python)

题目:原题链接(中等)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N)O(N)O(N)96ms (35.73%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minSteps(self, n: int) -> int: dp = [float("inf")] * (n + 1)
原创
26阅读
1评论
0点赞
发布博客于 3 月前

LeetCode题解(0646):最长数对链(Python)

题目:原题链接(中等)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N)O(N)O(N)2476ms (29.87%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def findLongestChain(self, pairs: List[List[int]]) -> int: pairs.sort
原创
21阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0640):求解一元一次方程(Python)

题目:原题链接(中等)标签:数学、字符串解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)40ms (52.71%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def solveEquation(self, equation: str) -> str: def count(ss):
原创
24阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0638):大礼包的最优选购方法(Python)

题目:原题链接(中等)标签:动态规划、深度优先搜索、记忆化递归解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NS)O(N^S)O(NS)O(N+S)O(N+S)O(N+S)84ms (81.82%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def __init__(self): self.price = [] self.specia
原创
32阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0611):有效三角形的个数(Python)

题目:原题链接(中等)标签:数组、二分查找解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2logN)O(N^2logN)O(N2logN)O(logN)O(logN)O(logN)712ms (24.14%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def triangleNumber(self, nums: List[int]) -> int:
原创
39阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0593):有效的正方形(Python)

题目:原题链接(中等)标签:数学、几何解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(1)O(1)O(1)O(1)O(1)O(1)28ms (98.79%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def validSquare(self, p1: List[int], p2: List[int], p3: List[int], p4: List[int]) -&g
原创
19阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0592):分数加减运算(Python)

题目:原题链接(中等)标签:数学、字符串解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)40ms (67.37%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def fractionAddition(self, expression: str) -> str: def analyse(ss):
原创
29阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0576):出界的路径数(Python)

题目:原题链接(中等)标签:动态规划、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(M×N×T)O(M×N×T)O(M×N×T)O(M×N×T)O(M×N×T)O(M×N×T)816ms (5.07%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def findPaths(self, m: int, n: int, t: int, ii: int, jj
原创
19阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0567):字符串的排列(Python)

题目:原题链接(中等)标签:数组、双指针、滑动窗口解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(S1+S2)O(S1+S2)O(S1+S2)O(S1)O(S1)O(S1)100ms (41.36%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def checkInclusion(self, s1: str, s2: str) -> bool:
原创
42阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0565):数组嵌套(Python)

题目:原题链接(中等)标签:动态规划、数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)172ms (16.33%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def arrayNesting(self, nums: List[int]) -> int: size = len(nums)
原创
38阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0558):四叉树交集(Python)

题目:原题链接(中等)标签:树、回溯算法、递归解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(logN)O(logN)O(logN)68ms (86.05%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def intersect(self, quadTree1: 'Node', quadTree2: 'Node') -> 'Node':
原创
35阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0542):01矩阵(Python)

题目:原题链接(中等)标签:广度优先搜索、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(M×N)O(M×N)O(M×N)O(M×N)O(M×N)O(M×N)756ms (49.79%)Ans 2 (Python)Ans 3 (Python)解法一(广度优先搜索):class Solution: def updateMatrix(self, matrix: List[List[int]]) -> Li
原创
35阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0540):有序数组中的单一元素(Python)

题目:原题链接(中等)标签:二分查找、位运算解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)48ms (18.94%)Ans 2 (Python)O(logN)O(logN)O(logN)O(1)O(1)O(1)32ms (95.20%)Ans 3 (Python)解法一(位运算):class Solution: def singleNonDuplicate(self, nu
原创
47阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0529):扫雷游戏(Python)

题目:原题链接(中等)标签:深度优先搜索、广度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(M×N)O(M×N)O(M×N)O(1)O(1)O(1)228ms (36.22%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def updateBoard(self, board: List[List[str]], click: List[int]) ->
原创
45阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0526):优美的排列(Python)

题目:原题链接(中等)标签:回溯算法、递归解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N!)O(N!)O(N!)O(N)O(N)O(N)1804ms (20.71%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def __init__(self): self.N = 0 self.ans = 0 self.now =
原创
31阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0524):通过删除字母匹配到字典里最长单词(Python)

题目:原题链接(中等)标签:排序、双指针解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN+NS)O(NlogN+NS)O(NlogN+NS)O(logN)O(logN)O(logN)632ms (39.11%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def findLongestWord(self, s: str, d: List[str]) ->
原创
27阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0523):连续的子数组和(Python)

题目:原题链接(中等)标签:哈希表、动态规划、数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)56ms (49.54%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def checkSubarraySum(self, nums: List[int], k: int) -> bool: visited
原创
25阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0518):零钱兑换II(Python)

题目:原题链接(中等)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N×C)O(N×C)O(N×C)O(N)O(N)O(N)136ms (86.70%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def change(self, amount: int, coins: List[int]) -> int: dp = [1] + [
原创
25阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0516):最长回文子序列(Python)

题目:原题链接(中等)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N2)O(N^2)O(N2)1172ms (84.53%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def longestPalindromeSubseq(self, s: str) -> int: size = len(s)
原创
25阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0498):对角线遍历(Python)

题目:原题链接(中等)标签:数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(M×N)O(M×N)O(M×N)O(1)O(1)O(1)208ms (76.56%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def findDiagonalOrder(self, matrix: List[List[int]]) -> List[int]: if
原创
18阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0495):提莫攻击(Python)

题目:原题链接(中等)标签:数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)284ms (74.87%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def findPoisonedDuration(self, timeSeries: List[int], duration: int) -> int:
原创
14阅读
0评论
0点赞
发布博客于 3 月前

LeetCode题解(0494):目标和(Python)

题目:原题链接(中等)标签:动态规划、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(2N)O(2^N)O(2N)O(2N)O(2^N)O(2N)超出时间限制Ans 2 (Python)O(N×2000)O(N×2000)O(N×2000)O(N×2000)O(N×2000)O(N×2000)220ms (57.52ms)Ans 3 (Python)解法一(回溯算法):class Solution: def
原创
19阅读
0评论
0点赞
发布博客于 3 月前