自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

数据艺术家

数据挖掘领域懵逼者

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

原创 LeetCode题解(0631):设计Excel求和公式(Python)

题目:原题链接(困难)标签:设计、图、拓扑排序解法时间复杂度空间复杂度执行用时Ans 1 (Python)SET = O(H×W)O(H×W)O(H×W) ; GET = O(1)O(1)O(1) ; SUM = O(H×W×S)O(H×W×S)O(H×W×S)O(H×W)O(H×W)O(H×W)36ms (92.00%)Ans 2 (Python)Ans 3 (Python)解法一:class Excel: def __init_

2020-12-09 12:30:46 6

原创 LeetCode题解(0963):最小面积矩形II(Python)

题目:原题链接(中等)标签:几何、数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2logN)O(N^2logN)O(N2logN)O(N2)O(N^2)O(N2)92ms (92.68%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minAreaFreeRect(self, points: List[List[int]]) -> float:

2020-12-08 22:44:37 47

原创 LeetCode题解(0587):安装栅栏(Python)

题目:原题链接(困难)标签:几何、数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN)O(NlogN)O(NlogN)O(N)O(N)O(N)108ms (87.27%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def orientation(self, p, q, r): return (q[1] - p[1]) * (r[0] - q

2020-12-08 22:44:33 49

原创 LeetCode题解(1668):最大重复子字符串(Python)

题目:原题链接(简单)标签:字符串、双指针解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N1×N2)O(N1×N2)O(N1×N2)O(1)O(1)O(1)36ms (76.94%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def maxRepeating(self, sequence: str, word: str) -> int: s1,

2020-12-08 22:44:29 88

原创 LeetCode题解(1652):拆炸弹(Python)

题目:原题链接(简单)标签:数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)52ms (44.78%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def decrypt(self, code: List[int], k: int) -> List[int]: if k == 0:

2020-12-08 22:44:26 75

原创 LeetCode题解(1528):重新排列字符串(Python)

题目:原题链接(简单)标签:数组、排序解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)48ms (46.84%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def restoreString(self, s: str, indices: List[int]) -> str: res = [""] * l

2020-12-08 22:44:22 80

原创 LeetCode题解(1523):在区间范围内统计奇数数目(Python)

题目:原题链接(简单)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(1)O(1)O(1)O(1)O(1)O(1)44ms (33.75%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def countOdds(self, low: int, high: int) -> int: if (high - low) % 2 == 1:

2020-12-08 22:44:18 44

原创 LeetCode题解(0228):汇总区间(Python)

题目:原题链接(简单)标签:数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)36ms (77.80%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def summaryRanges(self, nums: List[int]) -> List[str]: if not nums:

2020-12-08 22:44:14 29

原创 LeetCode题解(LCP22):黑白方格画(Python)

题目:原题链接(简单)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N)O(N)O(N)32ms (93.87%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def paintingPlan(self, n: int, k: int) -> int: if k == n * n:

2020-12-08 22:44:09 179

原创 LeetCode题解(LCP17):速算机器人(Python)

题目:原题链接(简单)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(S)O(S)O(S)O(1)O(1)O(1)32ms (94.86%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def calculate(self, s: str) -> int: x, y = 1, 0 for ch in s:

2020-12-08 22:44:03 38

原创 LeetCode题解(LCP11):期望个数统计(Python)

题目:原题链接(简单)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)76ms (76.95%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def expectNumber(self, scores: List[int]) -> int: return len(set(scores)).

2020-12-08 22:43:58 83

原创 LeetCode题解(0588):设计内存文件系统(Python)

题目:原题链接(困难)标签:设计解法时间复杂度空间复杂度执行用时Ans 1 (Python)––80ms (25.00%)Ans 2 (Python)Ans 3 (Python)解法一:class FileSystem: class Folder: def __init__(self): self.dir = {} self.file = {} class Fi

2020-12-08 17:22:20 6

原创 LeetCode题解(0573):松鼠模拟(Python)

题目:原题链接(中等)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)216ms (8.33%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minDistance(self, height: int, width: int, tree: List[int], squirrel: List[int], nut

2020-12-08 17:01:14 18

原创 LeetCode题解(0568):最大休假天数(Python)

题目:原题链接(困难)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2K)O(N^2K)O(N2K)O(N)O(N)O(N)1472ms (100.00%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def maxVacationDays(self, flights: List[List[int]], days: List[List[int]]) -

2020-12-08 15:25:44 6

原创 LeetCode题解(0562):矩阵中最长的连续1线段(Python)

题目:原题链接(中等)标签:数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N×M)O(N×M)O(N×M)O(1)O(1)O(1)616ms (41.82%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def longestLine(self, M: List[List[int]]) -> int: if not M or not M[0]

2020-12-08 15:08:19 32

原创 LeetCode题解(0548):将数组分割成和相等的子数组(Python)

题目:原题链接(中等)标签:数组、哈希表解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N)O(N)O(N)2068ms (38.98%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def splitArray(self, nums: List[int]) -> bool: # 计算前缀和 pref

2020-12-08 14:48:32 11

原创 LeetCode题解(0555):分割连接字符串(Python)

题目:原题链接(中等)标签:字符串解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N)O(N)O(N)68ms (72.58%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def splitLoopedString(self, strs: List[str]) -> str: lst = [] fo

2020-12-08 14:48:13 38

原创 LeetCode题解(0533):孤独像素II(Python)

题目:原题链接(中等)标签:数组、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N×M)O(N×M)O(N×M)O(N×M)O(N×M)O(N×M)548ms (55.10%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def findBlackPixel(self, picture: List[List[str]], N: int) -> int

2020-12-08 12:48:12 3

原创 LeetCode题解(0531):孤独像素I(Python)

题目:原题链接(中等)标签:数组、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N×M)O(N×M)O(N×M)O(N×M)O(N×M)O(N×M)76ms (97.67%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def findLonelyPixel(self, picture: List[List[str]]) -> int:

2020-12-08 12:29:38 1

原创 LeetCode题解(0527):单词缩写(Python)

题目:原题链接(困难)标签:字符串、排序、字典树、贪心算法解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)2296ms (6.00%)Ans 2 (Python)Ans 3 (Python)解法一:class TrieNode: def __init__(self): self.num = collections.Counter() self.

2020-12-08 12:23:43

原创 LeetCode题解(0499):迷宫III(Python)

题目:原题链接(困难)标签:广度优先搜索、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)84ms (53.06%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def __init__(self): self.visited = set() self.maze = []

2020-12-08 11:49:35 4

原创 LeetCode题解(0505):迷宫II(Python)

题目:原题链接(中等)标签:广度优先搜索、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)376ms (66.67%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def __init__(self): self.maze = [] def shortestDistance(self, m

2020-12-08 11:16:40 9

原创 LeetCode题解(0489):扫地机器人(Python)

题目:原题链接(困难)标签:回溯算法、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(4N−M)O(4^{N-M})O(4N−M)O(N−M)O(N-M)O(N−M)92ms (30.19%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: _DIRECTIONS = [(0, 1), (1, 0), (0, -1), (-1, 0)] def __i

2020-12-08 11:05:47 47

原创 LeetCode题解(0490):迷宫(Python)

题目:原题链接(中等)标签:广度优先搜索、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)184ms (12.29%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def __init__(self): self.maze = [] def hasPath(self, maze: List

2020-12-08 11:05:19 8

原创 LeetCode题解(0487):最大连续1的个数II(Python)

题目:原题链接(中等)标签:数组、双指针解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)468ms (63.10%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def findMaxConsecutiveOnes(self, nums: List[int]) -> int: ans = 1

2020-12-08 09:54:49 5

原创 LeetCode题解(0484):寻找排列(Python)

题目:原题链接(中等)标签:贪心算法、数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)100ms (59.57%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def findPermutation(self, s: str) -> List[int]: lst = [[0]] for

2020-12-08 09:50:37 1

原创 LeetCode题解(0471):编码最短长度的字符串(Python)

题目:原题链接(困难)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N3)O(N^3)O(N3)O(N2)O(N^2)O(N2)204ms (67.86%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def encode(self, s: str) -> str: size = len(s) dp = [[""]

2020-12-08 09:41:04 11

原创 LeetCode题解(0469):凸多边形(Python)

题目:原题链接(中等)标签:几何、数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)232ms (62.96%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def isConvex(self, points: List[List[int]]) -> bool: size = len(points)

2020-12-08 09:10:32 24

原创 LeetCode题解(0465):最优账单平衡(Python)

题目:原题链接(困难)标签:回溯算法、图解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N2)O(N^2)O(N2)868ms (25.67%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def __init__(self): self.people = [] self.count = collectio

2020-12-08 09:10:28 13

原创 LeetCode题解(0425):单词方块(Python)

题目:原题链接(困难)标签:回溯算法、字典树解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(W×L2)O(W×L^2)O(W×L2)O(W×L2)O(W×L^2)O(W×L2)264ms (97.67%)Ans 2 (Python)Ans 3 (Python)解法一:def build_tree(words): tree = {} for i, word in enumerate(words):

2020-12-08 09:10:23 1

原创 LeetCode题解(0418):屏幕可显示句子的数量(Python)

题目:原题链接(中等)标签:动态规划、哈希表解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N×C)O(N×C)O(N×C)O(S)O(S)O(S)超出时间限制Ans 2 (Python)O(C×T)O(C×T)O(C×T) : 其中T为循环节所用行数O(S+T)O(S+T)O(S+T)268ms (70.00%)Ans 3 (Python)解法一(完全暴力):class Solution: def wordsTypi

2020-12-08 06:50:32

原创 LeetCode题解(0411):最短特异单词缩写(Python)

题目:原题链接(困难)标签:位运算、回溯算法解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(2N×M)O(2^N×M)O(2N×M)O(2N)O(2^N)O(2N)932ms (25.00%)Ans 2 (Python)Ans 3 (Python)解法一(暴力解法):class Solution: def minAbbreviation(self, target: str, dictionary: List[str])

2020-12-08 06:32:16

原创 LeetCode题解(LCP26):导航装置(Python)

题目:原题链接(困难)标签:树、二叉树、动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)896ms (94.74%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: # 对于每个三叉节点,至少有两边需要放导航 def __init__(self): self.ans = 0 def na

2020-12-07 22:05:51 42

原创 LeetCode题解(LCP07):传递信息(Python)

题目:原题链接(简单)标签:图、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NK)O(N^K)O(NK)O(NK)O(N^K)O(NK)52ms (39.84%)Ans 2 (Python)Ans 3 (Python)解法一:def build_graph(edges): graph = collections.defaultdict(set) for edge in edges:

2020-12-07 22:05:36 41

原创 LeetCode题解(LCP06):拿硬币(Python)

题目:原题链接(简单)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)44ms (35.31%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minCount(self, coins: List[int]) -> int: return sum((coin + 1) // 2 for c

2020-12-07 22:05:32 131

原创 LeetCode题解(LCP03):机器人大冒险(Python)

题目:原题链接(中等)标签:几何、数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N+M)O(N+M)O(N+M) : 其中N为命令长度,M为障碍数量O(M)O(M)O(M)28ms (99.58%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def robot(self, command: str, obstacles: List[List[int]], x:

2020-12-07 22:05:29 37

原创 LeetCode题解(LCP02):分式化简(Python)

题目:原题链接(简单)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)36ms (82.12%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def fraction(self, cont: List[int]) -> List[int]: n1, n2 = cont.pop(), 1

2020-12-07 22:05:26 58

原创 LeetCode题解(LCP01):猜数字(Python)

题目:原题链接(简单)标签:数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)28ms (98.29%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def game(self, guess: List[int], answer: List[int]) -> int: ans = 0 f

2020-12-07 22:05:18 45

原创 LeetCode题解(0528):按权重随机选择(Python)

题目:原题链接(中等)标签:随机、二分查找解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(logW)O(logW)O(logW)O(W)O(W)O(W)312ms (43.72%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def __init__(self, w: List[int]): self.nums = w self.pr

2020-12-07 22:05:15 51 1

原创 LeetCode题解(0519):随机翻转矩阵(Python)

题目:原题链接(中等)标签:随机、哈希表解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(1)O(1)O(1)O(F)O(F)O(F)68ms (74.07%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def __init__(self, n_rows: int, n_cols: int): self.n_rows, self.n_cols = n_

2020-12-07 22:05:11 43

空空如也

空空如也

空空如也

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

TA关注的人 TA的粉丝

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