自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

数据艺术家

数据挖掘领域懵逼者

  • 博客(262)
  • 收藏
  • 关注

原创 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:

2021-01-31 23:25:19 19

原创 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

2021-01-31 23:25:16 27

原创 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:

2021-01-31 23:25:11 13

原创 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"

2021-01-31 23:24:59 71

原创 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

2021-01-31 23:24:51 22

原创 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

2021-01-31 23:24:42 25

原创 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]) -

2021-01-31 23:24:38 34

原创 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]) -&gt

2021-01-31 23:24:29 16

原创 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

2021-01-31 23:24:22 33 1

原创 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

2021-01-31 23:24:14 17

原创 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

2021-01-30 23:05:44 16

原创 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

2021-01-30 23:05:40 24

原创 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

2021-01-30 23:05:35 21

原创 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]]) ->

2021-01-30 23:05:32 21

原创 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]

2021-01-30 23:05:23 54

原创 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:

2021-01-30 23:05:19 15

原创 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

2021-01-30 23:05:15 14

原创 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

2021-01-30 23:05:08 37

原创 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

2021-01-30 23:04:53 21

原创 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:

2021-01-30 23:04:39 27

原创 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: #

2021-01-29 10:00:48 35

原创 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:

2021-01-29 10:00:45 24

原创 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]]) -&gt

2021-01-29 10:00:40 23 1

原创 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 =

2021-01-29 10:00:35 35

原创 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

2021-01-29 10:00:31 23

原创 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[

2021-01-29 10:00:28 111

原创 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:

2021-01-29 10:00:25 24

原创 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

2021-01-29 10:00:21 22

原创 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

2021-01-29 10:00:17 23

原创 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

2021-01-29 10:00:13 27

原创 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

2021-01-28 18:28:21 28

原创 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 # 局部倒置

2021-01-28 18:28:17 15

原创 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

2021-01-28 18:28:14 182

原创 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

2021-01-28 18:28:08 21 1

原创 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]]) ->

2021-01-28 18:28:01 33

原创 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:

2021-01-28 18:27:58 21

原创 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 : [

2021-01-28 18:27:54 22

原创 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) ->

2021-01-28 18:27:50 56 1

原创 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

2021-01-28 18:27:44 21

原创 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):

2021-01-28 18:27:37 31

空空如也

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人 TA的粉丝

提示
确定要删除当前文章?
取消 删除