自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(120)
  • 收藏
  • 关注

原创 LeetCode题解(1396):设计地铁系统(Python)

题目:原题链接(中等)标签:设计解法时间复杂度空间复杂度执行用时Ans 1 (Python)checkIn = O(1)O(1)O(1) ; checkOut = O(1)O(1)O(1) ; getAverageTime = O(1)O(1)O(1)O(S+P)O(S+P)O(S+P)200ms (85.40%)Ans 2 (Python)Ans 3 (Python)解法一:class UndergroundSystem: def

2021-02-23 21:22:45 375

原创 LeetCode题解(1395):统计作战单位数(Python)

题目:原题链接(中等)标签:数组、线段树解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(1)O(1)O(1)1156ms (19.28%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def numTeams(self, rating: List[int]) -> int: size = len(rating)

2021-02-23 21:22:41 243

原创 LeetCode题解(1391):检查网格中是否存在有效路径(Python)

题目:原题链接(中等)标签:深度优先搜索、广度优先搜索、并查集解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(M×N)O(M×N)O(M×N)O(M×N)O(M×N)O(M×N)2084ms (5.39%)Ans 2 (Python)Ans 3 (Python)解法一:class DSU1: def __init__(self, n: int): self._n = n self._ar

2021-02-23 21:22:37 239

原创 LeetCode题解(1390):四因数(Python)

题目:原题链接(中等)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NK)O(N\sqrt{K})O(NK​)O(1)O(1)O(1)1456ms (16.05%)Ans 2 (Python)Ans 3 (Python)解法一:def factors(n): res = [] k = 1 while k * k < n: if n % k == 0:

2021-02-23 21:22:34 246

原创 LeetCode题解(1387):将整数按权重排序(Python)

题目:原题链接(中等)标签:动态规划、图、排序解法时间复杂度空间复杂度执行用时Ans 1 (Python)––172ms (94.41%)Ans 2 (Python)––84ms (97.37%)Ans 3 (Python)解法一:class Solution: def getKth(self, lo: int, hi: int, k: int) -> int: dp = {1: 0} def

2021-02-23 21:21:09 272

原创 LeetCode题解(1386):安排电影院座位(Python)

题目:原题链接(中等)标签:贪心算法、数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(R)O(R)O(R)O(R)O(R)O(R)144ms (41.56%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def maxNumberOfFamilies(self, n: int, reservedSeats: List[List[int]]) -> int:

2021-02-23 21:21:04 657

原创 LeetCode题解(1376):通知所有员工所需的时间(Python)

题目:原题链接(中等)标签:深度优先搜索、广度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)(N)(N)(N)500ms (73.12%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def numOfMinutes(self, n: int, headID: int, manager: List[int], informTime: Lis

2021-02-23 21:20:22 304

原创 LeetCode题解(1375):灯泡开关III(Python)

题目:原题链接(中等)标签:数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)140ms (25.78%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def numTimesAllBlue(self, light: List[int]) -> int: ans = 0 stat =

2021-02-23 21:20:18 267

原创 LeetCode题解(1366):通过投票对团队排名(Python)

题目:原题链接(中等)标签:排序、数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN+N×P)O(NlogN+N×P)O(NlogN+N×P)O(N2)O(N^2)O(N2)72ms (41.48%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def rankTeams(self, votes: List[str]) -> str:

2021-02-23 21:04:10 525

原创 LeetCode题解(1362):最接近的因数(Python)

题目:原题链接(中等)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(logN)O(logN)O(logN)O(logN)O(logN)O(logN)448ms (12.00%)Ans 2 (Python)Ans 3 (Python)解法一:def factors(n): k = 1 while k * k < n: if n % k == 0: yiel

2021-02-23 21:04:07 267

原创 LeetCode题解(1361):验证二叉树(Python)

题目:原题链接(中等)标签:并查集、图解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)156ms (11.67%)Ans 2 (Python)Ans 3 (Python)解法一:class DSU1: def __init__(self, n: int): self._n = n self._array = [i for i in range(

2021-02-21 11:22:17 275

原创 LeetCode题解(1357):每隔n个顾客打折(Python)

题目:原题链接(中等)标签:设计解法时间复杂度空间复杂度执行用时Ans 1 (Python)构造 = O(N)O(N)O(N) ; getBill = O(N)O(N)O(N)O(N)O(N)O(N)208ms (22.47%)Ans 2 (Python)Ans 3 (Python)解法一:class Cashier: def __init__(self, n: int, discount: int, products: List[

2021-02-21 11:22:05 296

原创 LeetCode题解(1353):最多可以参加的会议数目(Python)

题目:原题链接(中等)标签:贪心算法、排序、堆、线段树解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N+K)O(N+K)O(N+K)O(N)O(N)O(N)440ms (55.15%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def maxEvents(self, events: List[List[int]]) -> int: events

2021-02-21 11:21:51 495

原创 LeetCode题解(1352):最后K个数的乘积(Python)

题目:原题链接(中等)标签:设计、数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)add = O(1)O(1)O(1) ; getProduct = O(1)O(1)O(1)O(N)O(N)O(N)252ms (75.38%)Ans 2 (Python)Ans 3 (Python)解法一:class ProductOfNumbers: def __init__(self): self.array =

2021-02-21 11:21:47 202

原创 LeetCode题解(1348):推文计数(Python)

题目:原题链接(中等)标签:设计、有序映射解法时间复杂度空间复杂度执行用时Ans 1 (Python)recordTweet = O(1)O(1)O(1) ; getTweetCountsFrequency = O(NlogN)O(NlogN)O(NlogN)O(N)O(N)O(N)208ms (89.47%)Ans 2 (Python)Ans 3 (Python)解法一:class TweetCounts: _FREQUENTY =

2021-02-21 11:21:43 248

原创 LeetCode题解(1344):时钟指针的夹角(Python)

题目:原题链接(中等)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(1)O(1)O(1)O(1)O(1)O(1)36ms (76.64%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def angleClock(self, hour: int, minutes: int) -> float: n1 = ((hour + minutes

2021-02-21 11:21:38 432

原创 LeetCode题解(1343):大小为K且平均值大于等于阈值的子数组数目(Python)

题目:原题链接(中等)标签:数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)156ms (50.00%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def numOfSubarrays(self, arr: List[int], k: int, threshold: int) -> int: thr

2021-02-21 11:21:35 247

原创 LeetCode题解(1338):数组大小减半(Python)

题目:原题链接(中等)标签:数组、贪心算法、哈希表解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN)O(NlogN)O(NlogN)O(N)O(N)O(N)108ms (79.26%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minSetSize(self, arr: List[int]) -> int: count = co

2021-02-21 11:21:30 325 1

原创 LeetCode题解(1334):阈值距离内邻居最少的城市(Python)

题目:原题链接(中等)标签:图、广度优先搜索、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N×E)O(N×E)O(N×E)O(N+E)O(N+E)O(N+E)912ms (37.33%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def findTheCity(self, n: int, edges: List[List[int]], distance

2021-02-21 11:21:26 386

原创 LeetCode题解(1333):餐厅过滤器(Python)

题目:原题链接(中等)标签:排序、数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN)O(NlogN)O(NlogN)O(N)O(N)O(N)64ms (51.65%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def filterRestaurants(self, restaurants: List[List[int]], veganFriendly:

2021-02-21 11:21:20 250

原创 LeetCode题解(1329):将矩阵按对角线排序(Python)

题目:原题链接(中等)标签:数组、排序解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(M×N×log(min(M,N)))O(M×N×log(min(M,N)))O(M×N×log(min(M,N)))O(min(M,N))O(min(M,N))O(min(M,N))44ms (97.99%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def diagonalSort

2021-02-10 22:24:39 533 2

原创 LeetCode题解(1319):连通网络的操作次数(Python)

题目:原题链接(中等)标签:并查集、广度优先搜索、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)312ms (16.07%)Ans 2 (Python)Ans 3 (Python)解法一:class DSU1: def __init__(self, n: int): self._n = n self._array = [i for

2021-02-10 22:24:35 414 3

原创 LeetCode题解(1318):或运算的最小翻转次数(Python)

题目:原题链接(中等)标签:位运算解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(logN)O(logN)O(logN)O(1)O(1)O(1)44ms (33.33%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minFlips(self, a: int, b: int, c: int) -> int: ans = 0

2021-02-10 22:24:30 305

原创 LeetCode题解(1314):矩阵区域和(Python)

题目:原题链接(中等)标签:数组、动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(M×N)O(M×N)O(M×N)O(M×N)O(M×N)O(M×N)1224ms (71.14%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def matrixBlockSum(self, mat: List[List[int]], K: int) -> List[Lis

2021-02-10 22:24:25 338

原创 LeetCode题解(1310):子数组异或查询(Python)

题目:原题链接(中等)标签:位运算解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)516ms (10.17%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def xorQueries(self, arr: List[int], queries: List[List[int]]) -> List[int]:

2021-02-10 22:24:20 255

原创 LeetCode题解(1300):转变数组后最接近目标值的数组和(Python)

题目:原题链接(中等)标签:二分查找、数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogT)O(NlogT)O(NlogT)O(1)O(1)O(1)88ms (35.75%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def findBestValue(self, arr: List[int], target: int) -> int:

2021-02-10 22:24:11 266

原创 LeetCode题解(1292):元素和小于等于阈值的正方形的最大边长(Python)

题目:原题链接(中等)标签:数组、二分查找解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(M×N)O(M×N)O(M×N)O(M×N)O(M×N)O(M×N)1092ms (57.48%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def maxSideLength(self, matrix: List[List[int]], threshold: int) -&gt

2021-02-10 22:24:07 347

原创 LeetCode题解(1291):顺次数(Python)

题目:原题链接(中等)标签:数组、回溯算法解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(1)O(1)O(1)O(1)O(1)O(1)28ms (98.59%)Ans 2 (Python)Ans 3 (Python)解法一:nums = []for i in range(2, 10): v1 = int("".join([str(j) for j in range(1, i + 1)])) v2 = int(

2021-02-10 22:23:58 251

原创 LeetCode题解(1288):删除被覆盖区间(Python)

题目:原题链接(中等)标签:排序、贪心算法、扫描线算法解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN)O(NlogN)O(NlogN)O(logN)O(logN)O(logN)52ms (50.73%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def removeCoveredIntervals(self, intervals: List[List[in

2021-02-10 22:23:53 255

原创 LeetCode题解(1286):字母组合迭代器(Python)

题目:原题链接(中等)标签:回溯算法、设计解法时间复杂度空间复杂度执行用时Ans 1 (Python)构造 = O(1)O(1)O(1) ; next = O(1)O(1)O(1) ; hasNext = O(1)O(1)O(1)O(1)O(1)O(1)60ms (85.15%)Ans 2 (Python)Ans 3 (Python)解法一:from scipy.special import combclass CombinationI

2021-02-10 22:23:11 375

原创 LeetCode题解(1254):统计封闭岛屿的数目(Python)

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

2021-02-09 20:55:53 433

原创 LeetCode题解(1283):使结果不超过阈值的最小除数(Python)

题目:原题链接(中等)标签:二分查找解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogK)O(NlogK)O(NlogK)O(1)O(1)O(1)364ms (20.09%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def smallestDivisor(self, nums: List[int], threshold: int) -> int:

2021-02-09 20:55:38 279

原创 LeetCode题解(1282):用户分组(Python)

题目:原题链接(中等)标签:贪心算法、数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)40ms (91.24%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def groupThePeople(self, groupSizes: List[int]) -> List[List[int]]: peop

2021-02-09 20:55:32 243

原创 LeetCode题解(1277):统计全为1的正方形子矩阵(Python)

题目:原题链接(中等)标签:动态规划、数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(M×N)O(M×N)O(M×N)O(M×N)O(M×N)O(M×N)160ms (88.15%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def countSquares(self, matrix: List[List[int]]) -> int: m,

2021-02-09 20:55:04 276

原创 LeetCode题解(1276):不浪费原料的汉堡制作方案(Python)

题目:原题链接(中等)标签:数学、贪心算法解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(1)O(1)O(1)O(1)O(1)O(1)44ms (55.43%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def numOfBurgers(self, tomatoSlices: int, cheeseSlices: int) -> List[int]:

2021-02-09 20:54:56 340

原创 LeetCode题解(1267):统计参与通信的服务器(Python)

题目:原题链接(中等)标签:并查集、图、数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(M×N)O(M×N)O(M×N)O(M×N)O(M×N)O(M×N)144ms (22.40%)Ans 2 (Python)Ans 3 (Python)解法一:class DSU2: def __init__(self): self._n = 0 self._parent = {}

2021-02-09 20:54:50 380

原创 LeetCode题解(1262):可被三整除的最大和(Python)

题目:原题链接(中等)标签:数学、动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN)O(NlogN)O(NlogN)O(N)O(N)O(N)84ms (83.69%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def maxSumDivThree(self, nums: List[int]) -> int: ans = 0

2021-02-09 20:54:15 307

原创 LeetCode题解(1253):重构2行二进制矩阵(Python)

题目:原题链接(中等)标签:贪心算法、数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)100ms (80.95%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def reconstructMatrix(self, upper: int, lower: int, colsum: List[int]) -> List[

2021-02-09 20:54:11 262

原创 LeetCode题解(1248):统计“优美子数组”(Python)

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

2021-02-09 20:54:08 281

原创 LeetCode题解(1217):黄金矿工(Python)

题目:原题链接(中等)标签:回溯算法、深度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O((MN)2)O((MN)^2)O((MN)2)O(M×N)O(M×N)O(M×N)1964ms (13.10%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int:

2021-02-09 20:54:03 718

Kaggle:tmdb-box-office-prediction(转结构化数据,用于 SQL 练习)

原数据源(将其训练集结构化): https://www.kaggle.com/c/tmdb-box-office-prediction/data 数据量级+建表语句(含字段含义注释)详见博客: https://dataartist.blog.csdn.net/article/details/132268426 共 15 个表: - movies:电影表 - belongs_to_collection:电影系列表 - person:人员表(演员与剧组人员) - cast_rela:电影与演员的关联表 - crew_rela:电影与剧组人员的关联表 - genres:电影体裁表 - genres_rela:电影与体裁关联表 - keywords:电影关键词表 - keywords_rela:电影与关键词关联表 - production_companies:电影制作公司表 - production_companies_rela:电影与制作公司关联表 - production_countries:电影制作国家表 ……

2023-08-14

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

TA关注的人

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