- 博客(146)
- 资源 (8)
- 收藏
- 关注
原创 LeetCode 55. Jump Game 时间复杂度(O(n))
class Solution: def canJump(self, nums: [int]) -> bool: nums_len = len(nums) nums_record = [False] * nums_len nums_record[0] = True max_step = 0 for i in range(nums_len): if nums_record[i] is Fals.
2022-01-26 22:26:18
5329
原创 LeetCode 53. Maximum Subarray 时间复杂度(O(n))
class Solution: def maxSubArray(self, nums: [int]) -> int: res = nums[0] res_max = res for num in nums[1:]: res = num if res < 0 else res + num res_max = max(res_max, res) return res_max
2022-01-26 00:18:39
363
原创 LeetCode 48. Rotate Image 时间复杂度(O(n))
import copyclass Solution: def rotate(self, matrix: [[int]]) -> None: cmatrix = copy.deepcopy(matrix) mlen = len(matrix) for i in range(mlen // 2): curr_len = mlen - i * 2 for j in range(curr_len - 1.
2022-01-26 00:07:56
757
原创 LeetCode 42. Trapping Rain Water 时间复杂度(O(n))
class Solution: def trap(self, height: List[int]) -> int: def one_search(height): pre_v = 0 res = [] for index, h in enumerate(height): if index == 0: pre_v = h .
2022-01-25 22:32:44
4743
原创 139. Word Break 时间复杂度(O(n))
时间复杂度(O(n*m))思想:动态规划class Solution: def wordBreak(self, s: str, wordDict: [str]) -> bool: if len(s) == 0: return True words = set(wordDict) res = [False] * len(s) for i in range(len(s)): if i > 0 .
2020-09-24 22:53:22
359
原创 474. Ones and Zeroes 时间复杂度(O(k*m*n))
时间复杂度(O(k*m*n)),思想:动态规划,0,1背包问题class Solution: def findMaxForm(self, strs: [str], m: int, n: int) -> int: dp = [[0] * (n + 1) for _ in range((m + 1))] for item in strs: c0 = item.count('0') c1 = item.count.
2020-09-14 19:28:13
154
原创 142. Linked List Cycle II 时间复杂度(O(n))
时间复杂度(O(n)),思想:快慢指针,位置记录# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): def detectCycle(self, head: ListNode) -> ListNode: p,.
2020-09-05 18:34:30
143
原创 138. Copy List with Random Pointer 时间复杂度(O(n))
时间复杂度(O(n)) 思想:先插再去"""# Definition for a Node.class Node: def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None): self.val = int(x) self.next = next self.random = random"""class Solution: def copyRa..
2020-09-05 17:57:52
135
原创 124. Binary Tree Maximum Path Sum 时间复杂度(O(n))
时间复杂度(O(n)),思想:后序遍历# Definition for a binary tree node.# class TreeNode:# def __init__(self, val=0, left=None, right=None):# self.val = val# self.left = left# self.right = rightclass Solution: def maxPathSum(self..
2020-09-05 15:26:22
157
原创 128. Longest Consecutive Sequence 时间复杂度(O(n))
时间复杂度(O(n)),思想:hash_setclass Solution: def longestConsecutive(self, nums: [int]) -> int: num_set, dup_num_set, max_len = set(nums), set(), 0 for num in nums: curr_len = 1 if num in dup_num_set: ..
2020-09-05 15:04:50
79
原创 114. Flatten Binary Tree to Linked List 时间复杂度(O(n))
时间复杂度(O(n)),思想:move# Definition for a binary tree node.# class TreeNode:# def __init__(self, val=0, left=None, right=None):# self.val = val# self.left = left# self.right = rightclass Solution: def flatten(self, roo.
2020-08-30 17:20:19
95
原创 98. Validate Binary Search Tree 时间复杂度(O(n))
时间复杂度(O(n)),思想:中序遍历# Definition for a binary tree node.# class TreeNode:# def __init__(self, val=0, left=None, right=None):# self.val = val# self.left = left# self.right = rightclass Solution: def isValidBST(self,
2020-08-30 13:09:43
138
原创 96. Unique Binary Search Trees 时间复杂度(O(n))
时间复杂度(O(n)),思想:动态规划class Solution: def numTrees(self, n: int) -> int: ts = [1, 1] for i in range(1, n): curr_num = 0 for j in range(i // 2 + 1): dup = 1 if j == i - j else 2 ..
2020-08-29 11:22:06
297
原创 85. Maximal Rectangle 时间复杂度(O(n))
时间复杂度(O(n)),思想:栈,同84. Largest Rectangle in Histogram 时间复杂度(O(n))https://blog.youkuaiyun.com/ziyue246/article/details/108251988class Solution: def maximalRectangle(self, matrix: [[str]]) -> int: if len(matrix) == 0: return 0 def lar.
2020-08-27 11:14:27
103
原创 84. Largest Rectangle in Histogram 时间复杂度(O(n))
时间复杂度(O(n)),思想:栈class Solution: def largestRectangleArea(self, heights: [int]) -> int: area, max_area = [], 0 for i, h in enumerate(heights): start = i while len(area) > 0 and area[-1][1] > h: .
2020-08-27 08:12:50
115
原创 LeetCode 79. Word Search 时间复杂度(O(n))
时间复杂度(O(n)),思想:深度优先遍历class Solution: def exist(self, board: [[str]], word: str) -> bool: board_pos = {} for i in range(len(board)): for j in range(len(board[i])): ch = board[i][j] if ch.
2020-08-26 19:47:18
191
原创 ubuntu环境配置
apt代理 :/etc/apt/apt.confsudo ubuntu-drivers autoinstallsudo update-alternatives --allsudo dkms install -m nvidia -v 440.82sudo apt install dkmssudo apt autoremovenvidia-smi
2020-06-20 08:25:35
165
原创 常用机器学习包安装
pip install sklearn jieba numpy scipy pandas gensim matplotlib pyplot pylab libsvm
2020-02-24 13:31:21
350
原创 目标检测算法对比, rcnn, fast-rcnn, faster-rcnn, yolo2, yolo3
RCNN 1. 在图像中确定约1000-2000个候选框 (使用选择性搜索,selective search等) 2. 每个候选框内图像块缩放至相同大小,并输入到CNN内进行特征提取 3. 对候选框中提取出的特征,使用分类器判别是否属于一个特定类 4. 对于属于某一特征的候选框,用回归器进一步调整其位置Fast RCNN 1. 在图像中确定约1000-2000个候选框...
2019-12-09 20:55:57
374
原创 494. Target Sum 时间复杂度(O(2^n))
思想:动态规划,提示一点,虽然时间复杂度是(O(2^n)),但是实际上在动态规划中,有些步数会得到优化import collectionsclass Solution: def findTargetSumWays(self, nums: [int], S: int) -> int: dp = {0: 1} for num in nums: ...
2019-11-14 20:50:10
544
原创 LeetCode 406. Queue Reconstruction by Height 时间复杂度(O(n))
时间复杂度(O(n)),思想:排序,规律from collections import dequeclass Solution: def reconstructQueue(self, people: [[]]) -> [[]]: people.sort(key=lambda k: k[0] + 1 / (k[1] + 1), reverse=True)...
2019-11-09 08:01:09
118
原创 vimrc简单设置
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936set termencoding=utf-8set encoding=utf-8set nuset numberset cursorlineset mouse=aset selection=exclusiveset selectmode=mouse,keyset ta...
2019-10-30 16:31:47
237
原创 LeetCode 394. Decode String 时间复杂度(O(n))
时间复杂度(O(n)),思想:栈class Solution: def decodeString(self, s: str) -> str: stack = [] for ch in s: if ch == ']': subs = '' while len...
2019-09-05 23:42:00
235
原创 nlp 处理流程
第一步:收集数据(已有的数据,互联网已有的公开数据,数据状态,是否是标准化数据,是否是可以直接使用的数据,是否是有label的数据)第二步:清洗数据(清理特殊符号,无意义字符,无用数据,质量差的数据)(导入数据,观察数据,数据清洗,数据汇总,文本清洗,数据预处理,数据提取,数据筛选,数据统计,数据输出)第三步:做特征(one-hot, tf-idf, word2vec, doc2vec,数据...
2019-07-14 14:10:46
496
原创 2019年6月互联网公司市值不完全统计
美股:2019/06/21 16:00:00(美东时间)港股:2019/06/24 16:00:00(北京时间)沪深:2019/06/24 15:00:00(北京时间)
2019-06-24 21:53:57
2428
原创 LeetCode 56. Merge Intervals 时间复杂度(O(nlogn))
时间复杂度(O(nlogn)),思想:复杂度主要在排序上class Solution: def merge(self, intervals: [[int]]) -> [[int]]: if len(intervals) < 2: return intervals intervals.sort(key=lambda k: k[0]) ...
2019-06-09 15:09:24
175
原创 LeetCode 55. Jump Game 时间复杂度(O(n))
时间复杂度(O(n)),思想:动态规划class Solution: def canJump(self, nums: [int]) -> bool: nums_len = len(nums) if nums[0] == 0 and nums_len > 1: return False path_status = [Fals...
2019-06-09 14:41:00
182
原创 LeetCode 42. Trapping Rain Water 时间复杂度(O(n))
时间复杂度(O(n)),思想:动态规划class Solution: def trap(self, height: [int]) -> int: trap_water = 0 start_index, start_h, end_index = -1, 0, len(height) while start_index < en...
2019-06-09 09:23:14
124
原创 LeetCode 412. Fizz Buzz 时间复杂度(O(n))
时间复杂度(O(n)),思想:取余class Solution: def fizzBuzz(self, n: int) -> [str]: r = [] for i in range(1, n + 1): if i % 5 == 0 and i % 3 == 0: r.append('F...
2019-05-28 17:47:18
79
原创 C++经典问题
1.new、delete、malloc、free关系a、malloc与free是C++/C语言的标准库函数,需要手动进行内存申请,释放;b、new/delete是C++的运算符,delete会调用对象的析构函数,new调用构造函数;c、它们都可用于申请动态内存和释放内存;2.delete与delete[]区别delete只会调用一次析构函数,而delete[]会调用每一个成...
2019-05-27 11:33:20
276
原创 crf笔记
CRF(conditional random field algorithm)求解用到的知识点是 viterbi+ lr( logistics regression)1、基本公式和是特征函数,转移特征函数,状态特征函数,和是对应的权值,是规范因子,求和是在所有可能的输出序列上进行的。2、化简设有个转移特征,个状态特征,3、简化版...
2019-05-26 12:29:26
315
原创 LeetCode 621. Task Scheduler 时间复杂度(O(n*m))
时间复杂度(O(n*m)),思想:排序class Solution: def leastInterval(self, tasks: [str], n: int) -> int: tasks_count = [0] * 26 for task in tasks: tasks_count[ord(task) - 65] +=...
2019-05-23 00:28:11
260
原创 LeetCode 64. Minimum Path Sum 时间复杂度(O(n^2))
时间复杂度(O(n^2)),思想:动态规划class Solution: def minPathSum(self, grid: List[List[int]]) -> int: for i in range(len(grid)): for j in range(len(grid[0])): if i &g...
2019-05-22 10:47:43
130
原创 LeetCode 215. Kth Largest Element in an Array 时间复杂度(O(n))
时间复杂度(O(n)),思想:快排import randomclass Solution: def findKthLargest(self, nums: [int], k: int) -> int: k, re_start, re_end = k - 1, 0, len(nums) - 1 while True: p...
2019-05-22 00:13:22
257
原创 LeetCode 48. Rotate Image 时间复杂度(O(n))
时间复杂度(O(n)),思想:细心,耐心class Solution: def rotate(self, matrix: [[int]]) -> None: n = len(matrix) for i in range(n // 2): for j in range(i, n - i - 1): ...
2019-05-19 19:59:48
221
原创 LeetCode 102. Binary Tree Level Order Traversal 时间复杂度(O(n))
时间复杂度(O(n)),思想:队列层次遍历# Definition for a binary tree node.# class TreeNode:# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneimport queue...
2019-05-19 18:20:32
101
VC++6.0_win10兼容_番茄助手
2018-07-27
豆瓣20万条影评数据集.txt
2018-07-15
豆瓣5万条影评数据集
2018-07-04
一种新的图像清晰度评价函数
2015-12-09
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人