自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

数据艺术家

数据挖掘领域懵逼者

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

原创 LeetCode题解(1745):回文串分割IV(Python)

题目:原题链接(困难)标签:动态规划、广度优先搜索、字符串解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N2)O(N^2)O(N2)3568ms (59.08%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def checkPartitioning(self, s: str) -> bool: size = le

2021-04-24 09:45:02 5

原创 LeetCode题解(1744):你能在你最喜欢的那天吃到你最喜欢的糖果吗?(Python)

题目:原题链接(中等)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(C+Q)O(C+Q)O(C+Q)O(C)O(C)O(C)248ms (40.47%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def canEat(self, candies_count: List[int], queries: List[List[int]]) -> List[b

2021-04-24 09:44:57 58

原创 LeetCode题解(1743):从相邻元素对还原数组(Python)

题目:原题链接(中等)标签:哈希表、贪心算法解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)520ms (20.76%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def restoreArray(self, adjacentPairs: List[List[int]]) -> List[int]: n

2021-04-24 09:44:52 20

原创 LeetCode题解(1742):盒子中小球的最大数量(Python)

题目:原题链接(简单)标签:数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(high−low)O(high-low)O(high−low)O(1)O(1)O(1)356ms (89.14%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def countBalls(self, lowLimit: int, highLimit: int) -> int:

2021-04-24 09:44:48 26

原创 LeetCode题解(1808):好因子的最大数目(Python)

题目:原题链接(困难)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(1)O(1)O(1)O(1)O(1)O(1)32ms (95.80%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: _MOD = 10 ** 9 + 7 # 相当于找n个数,它们的和为primeFactors,求乘积的最大值 def maxNiceDivisors(self

2021-04-24 09:44:31 3

原创 LeetCode题解(1807):替换字符串中的括号内容(Python)

题目:原题链接(中等)标签:哈希表、字符串解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(S+K)O(S+K)O(S+K)O(K)O(K)O(K)192ms (69.89%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def evaluate(self, s: str, knowledge: List[List[str]]) -> str: kn

2021-04-24 09:44:26 40

原创 LeetCode题解(1806):还原排列的最少操作步数(Python)

题目:原题链接(中等)标签:贪心算法、数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)36ms (96.90%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def reinitializePermutation(self, n: int) -> int: if n == 2:

2021-04-24 09:44:20 17

原创 LeetCode题解(1805):字符串中不同整数的数目(Python)

题目:原题链接(简单)标签:字符串解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)48ms (22.66%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def numDifferentIntegers(self, word: str) -> int: ans = [""] for ch

2021-04-24 09:44:15 6

原创 LeetCode题解(1739):放置盒子(Python)

题目:原题链接(困难)标签:二分查找、数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(logN)O(logN)O(logN)O(1)O(1)O(1)44ms (76.07%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minimumBoxes(self, n: int) -> int: # ---------- 二分计算可以堆放的最大

2021-04-24 09:44:11 13

原创 LeetCode题解(1738):找出第K大的异或坐标值(Python)

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

2021-04-24 09:44:06 35

原创 LeetCode题解(1737):满足三条件之一需改变的最少字符数(Python)

题目:原题链接(中等)标签:贪心算法、字符串解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(A+B)O(A+B)O(A+B)O(1)O(1)O(1)240ms (56.96%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minCharacters(self, a: str, b: str) -> int: # ---------- 计算每

2021-04-23 23:24:49 3

原创 LeetCode题解(1736):替换隐藏数字得到的最晚时间(Python)

题目:原题链接(简单)标签:字符串、贪心算法解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(1)O(1)O(1)O(1)O(1)O(1)44ms (29.53%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def maximumTime(self, time: str) -> str: hour, minute = time.split(":")

2021-04-23 23:24:38 19

原创 LeetCode题解(1735):生成乘积数组的方案数(Python)

题目:原题链接(困难)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(10000+QlogN)O(10000+QlogN)O(10000+QlogN)O(10000+Q)O(10000+Q)O(10000+Q)224ms (90.31%)Ans 2 (Python)Ans 3 (Python)解法一:# 求n以下的质数def get_primes(n: int) -> list: if n <

2021-04-23 23:24:33 13

原创 LeetCode题解(1734):解码异或后的排列(Python)

题目:原题链接(中等)标签:位运算、数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N×B)O(N×B)O(N×B)O(B)O(B)O(B)1964ms (5.06%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def decode(self, encoded: List[int]) -> List[int]: n = len(encoded

2021-04-23 23:24:28 42

原创 LeetCode题解(1733):需要教语言的最少人数(Python)

题目:原题链接(中等)标签:贪心算法解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(L+F)O(L+F)O(L+F)O(L+N)O(L+N)O(L+N)140ms (97.89%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minimumTeachings(self, n: int, languages: List[List[int]], friendship

2021-04-23 23:24:24 18

原创 LeetCode题解(1732):找到最高海拔(Python)

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

2021-04-23 23:24:19 19

原创 LeetCode题解(0995):K连续位的最小翻转次数(Python)

题目:原题链接(困难)标签:贪心算法、滑动窗口解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)908ms (53.33%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minKBitFlips(self, A: List[int], k: int) -> int: # 处理K=1的特殊情况

2021-04-23 23:24:13 29

原创 LeetCode题解(0765):情侣牵手(Python)

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

2021-04-23 23:24:09 38

原创 LeetCode题解(0480):滑动窗口中位数(Python)

题目:原题链接(困难)标签:堆、滑动窗口解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(NlogN)O(NlogN)O(NlogN)O(N)O(N)O(N)164ms (45.09%)Ans 2 (Python)Ans 3 (Python)解法一:class MedianQueue: def __init__(self): self._left = self._right = 0 # 当前数组中比中位

2021-04-23 23:24:04 18

原创 LeetCode题解(1489):找到最小生成树里的关键边和伪关键边(Python)

题目:原题链接(困难)标签:并查集、深度优先搜索、图解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(E2)O(E^2)O(E2)O(N+E)O(N+E)O(N+E)1984ms (25.00%)Ans 2 (Python)Ans 3 (Python)解法一:class DSU1: def __init__(self, n: int): self._n = n self._array =

2021-04-23 23:23:55 11

原创 【ECharts实例】3D曲面图+散点图

option = { tooltip: { shadowColor: 'rgba(0, 0, 0, 0)' }, backgroundColor: '#fff', visualMap: [{ show: false, dimension: 2, min: 0, max: 25, seriesIndex: 0, inRange: { colo.

2021-04-18 13:41:26 84

原创 LeetCode题解(0635):设计日志存储系统(Python)

题目:原题链接(中等)标签:设计、字符串解法时间复杂度空间复杂度执行用时Ans 1 (Python)put = O(1)O(1)O(1) ; retrieve = O(N)O(N)O(N)O(N)O(N)O(N)48ms (96.55%)Ans 2 (Python)Ans 3 (Python)解法一:TIME_LENGTH = { "Year": 4, "Month": 7, "Day": 10, "Hour"

2021-04-02 19:30:47 30 1

原创 LeetCode题解(0634):寻找数组的错位排列(Python)

题目:原题链接(中等)标签:动态规划、数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)460ms (18.18%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: _MOD = 10 ** 9 + 7 def findDerangement(self, n: int) -> int: dp =

2021-04-02 19:30:43 10

原创 LeetCode题解(1728):猫和老鼠II(Python)

题目:原题链接(困难)标签:动态规划解法时间复杂度空间复杂度执行用时Ans 1 (Python)––520ms (96.20%)Ans 2 (Python)Ans 3 (Python)解法一(贪心算法):class Solution: def canMouseWin(self, grid: List[str], catJump: int, mouseJump: int) -> bool: def _is_vali

2021-04-02 19:30:37 26

原创 LeetCode题解(1727):重新排列后的最大子矩阵(Python)

题目:原题链接(中等)标签:贪心算法、排序解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(×N)O(×N)O(×N)O(M×N)O(M×N)O(M×N)348ms (60.38%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def largestSubmatrix(self, matrix: List[List[int]]) -> int: m,

2021-04-02 19:30:34 25 1

原创 LeetCode题解(1726):同积元组(Python)

题目:原题链接(中等)标签:数组、哈希表解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N2)O(N^2)O(N2)2432ms (6.75%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def tupleSameProduct(self, nums: List[int]) -> int: count = coll

2021-04-02 19:30:30 9

原创 LeetCode题解(1725):可以形成最大正方形的矩形数目(Python)

题目:原题链接(简单)标签:贪心算法解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)52ms (74.05%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def countGoodRectangles(self, rectangles: List[List[int]]) -> int: max_val,

2021-04-02 19:30:26 9

原创 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},完成了统计学习方法的第一个要素:模型。下面考虑按照要按照什么样的准则从假设空间中选取最优模型,即统计学习方法的第二个要素:策略。即当训练数据集线性可分时,如何找出可以将正实例点和

2021-04-02 19:28:14 24

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

2021-04-02 19:19:12 76 1

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

2021-04-02 18:26:11 232

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

2021-04-02 18:18:28 60

原创 LeetCode题解(LCP23):魔术排列(Python)

题目:原题链接(中等)标签:贪心算法解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N)O(N)O(N)52ms (68.42%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def isMagic(self, target: List[int]) -> bool: n = len(target)

2021-04-01 13:36:39 21

原创 LeetCode题解(1654):到家的最少跳跃次数(Python)

题目:原题链接(中等)标签:广度优先搜索、动态规划、记忆化递归解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(6000)O(6000)O(6000)O(6000)O(6000)O(6000)92ms (60.89%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: _BIG = 6001 def minimumJumps(self, forbidden: List

2021-04-01 13:36:35 29

原创 LeetCode题解(1653):使字符串平衡的最少删除次数(Python)

题目:原题链接(中等)标签:贪心算法、字符串解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(N)O(N)O(N)1392ms (34.69%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def minimumDeletions(self, s: str) -> int: size = len(s) lst

2021-04-01 13:36:30 9

原创 LeetCode题解(1546):和为目标值的最大数目不重叠非空子数组数目(Python)

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

2021-04-01 13:36:24 9

原创 LeetCode题解(1524):和为奇数的子数组数目(Python)

题目:原题链接(中等)标签:数组、数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)272ms (27.03%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: _MOD = 10 ** 9 + 7 def numOfSubarrays(self, arr: List[int]) -> int:

2021-04-01 13:36:20 11

原创 LeetCode题解(1514):概率最大的路径(Python)

题目:原题链接(中等)标签:图解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2)O(N^2)O(N2)O(N)O(N)O(N)280ms (33.75%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def maxProbability(self, n: int, edges: List[List[int]], succProb: List[float], star

2021-04-01 13:36:16 20

原创 LeetCode题解(1465):切割后面积最大的蛋糕(Python)

题目:原题链接(中等)标签:数组解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(HlogH+VlogV)O(HlogH+VlogV)O(HlogH+VlogV)O(logH+logV)O(logH+logV)O(logH+logV)120ms (77.67%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: _MOD = 10 ** 9 + 7 def maxAr

2021-04-01 13:36:12 14

原创 LeetCode题解(1462):课程安排IV(Python)

题目:原题链接(中等)标签:图、拓扑排序、广度优先搜索解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N+P+Q)O(N+P+Q)O(N+P+Q)O(N+P)O(N+P)O(N+P)124ms (98.84%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def checkIfPrerequisite(self, n: int, prerequisites: List[

2021-04-01 13:36:08 6

原创 LeetCode题解(1447):最简分数(Python)

题目:原题链接(中等)标签:数学解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N2logN)O(N^2logN)O(N2logN)O(1)O(1)O(1)104ms (73.83%)Ans 2 (Python)Ans 3 (Python)解法一:class Solution: def simplifiedFractions(self, n: int) -> List[str]: ans = []

2021-04-01 13:36:05 11

空空如也

空空如也

空空如也

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

TA关注的人 TA的粉丝

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