惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Cisco Talos Blog
Cisco Talos Blog
P
Privacy & Cybersecurity Law Blog
I
Intezer
Y
Y Combinator Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
N
Netflix TechBlog - Medium
The Hacker News
The Hacker News
AWS News Blog
AWS News Blog
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Stack Overflow Blog
Stack Overflow Blog
Hacker News: Ask HN
Hacker News: Ask HN
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog
T
Tor Project blog
C
Cybersecurity and Infrastructure Security Agency CISA
云风的 BLOG
云风的 BLOG
博客园_首页
V2EX - 技术
V2EX - 技术
T
Threat Research - Cisco Blogs
腾讯CDC
宝玉的分享
宝玉的分享
博客园 - 叶小钗
罗磊的独立博客
S
Securelist
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
Scott Helme
Scott Helme
博客园 - 司徒正美
W
WeLiveSecurity
有赞技术团队
有赞技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Secure Thoughts
NISL@THU
NISL@THU
N
News and Events Feed by Topic
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
雷峰网
雷峰网
大猫的无限游戏
大猫的无限游戏
K
Kaspersky official blog
IT之家
IT之家

LeetCode

二分查找 mid 什么时候要加 1 - V2EX 大家知道哔站或者 Youtube 上有木有出 leetcode 刷题讲解视频的博主? - V2EX leetcode 到达 1000 题了🎉 - V2EX 为什么打开 leetcode 中文网要验证手机号啊,能不验证吗 - V2EX 为什么要刷算法? - V2EX 靓仔们,刷的第一个道 leetcode 题是什么哇 - V2EX Leecode 组队刷题 - V2EX 2018 年之前大家怎么准备的面试? - V2EX 142. 环形链表 II 我这么写为什么有个 case 无法通过 - V2EX 各位都是怎么刷题的 - V2EX leetcode 第 402 题,移除 K 位数字 的疑问 - V2EX 你力扣做几题了?做题数还能衡量水平吗?我做了很多题还是很菜 - V2EX leetcode-cn 年费会员 20%off - V2EX LeetCode 有史以来最简单的题目 - V2EX 一直很好奇 leetcode 是怎么判断随机算法的正误的 - V2EX 你们会在意执行用时和内存消耗吗? - V2EX leetcode 502badgateway 了? - V2EX 开心,参加 Weekly Contest 270 不到 1 小时解决了 3 题, Q3 最后几十秒提交一次性通过 - V2EX 刷题,组队 - V2EX 早安刷题 - V2EX leetcode 33 解法求解释 - V2EX 大家刷题,是去中文的 leetcode-cn.com,还是去 leetcode.com?貌似还有一个山寨的 lintcode - V2EX 刷同一类题型真是很不错的方法 - V2EX leetcode 1758 - V2EX 3 个月 了 刷了 51 道题 平均每道题 3 种左右的方法 区间合并 断断续续想了 2 天 执行时间竟然 100% 两次提交 代码没有变动 竟然时间还不一样 一起来刷题 - V2EX 30 天 LeetCode 从 100 题刷到 200 题,再次发帖留念 - V2EX 被今天的 LeetCode 打卡题搞吐了,思路和代码都和题解基本一样,但就是一直超时不过 - V2EX LeetCode 中使用 StringBuilder 连接字符串为什么会比用+号连接快? 刷题很痛苦 需要自己找方法刺激过程 别放弃 - V2EX leetcode 有排名了,每天起来看自己排名上涨也是一种乐趣 认认真真地刷题 提高代码能力和思维能力 - V2EX 刷了 10 题 leetcode,感觉身体被掏空 - V2EX 大家觉得 backtracking 难吗? - V2EX 国内本科学生,想问问大佬们 Leetcode 推荐美国站还是国内站 - V2EX 华为 OD 机试题:给定两个数 0<S, N<100000, S 为数列总和, N 为数列长度,求连续正整数列 LeetCode 2020 感恩节促销开始 - V2EX 求分享 416 的衍生问题的解题思路 LeetCode 有关 树 的题到底怎么套输入 - V2EX 有没有正在刷 LeetCode 的小伙伴们? - V2EX 九章算法 | 字节跳动面试题:用 Rand7()实现 Rand10() - V2EX 长文慎点! Kaggle 比赛的 top2%和金牌到底差距有多大? - V2EX 微软面试真题+面试官改编 leetcode 思路(哈希篇-加更) - V2EX 微软面试真题+面试官改编 leetcode 思路(链表篇) - V2EX
Leetcode 刷题记录 - V2EX
Knuth · 2022-07-29 · via LeetCode
Knuth

10

Knuth      2022 年 8 月 7 日

2020/8/7
快速排序
关于边界条件 https://www.acwing.com/solution/content/16777/
这篇题解讲的很不错,个人喜欢用 j 做边界,所以 pivot=nums[l],对于用 i 做边界,则需要同 j 的情况取反。对于数据增强的情况下 pivot 取 nums[(l+r)/2]或随机化加快速度
``` cpp
void quick_sort(vector<int>& nums, int l, int r) {
if(l >= r) {
return ;
}
// int pivot = (r + l) / 2;
int pivot = l + rand() % (r - l + 1);
// 注意基准元素应当取出来比较
int x = nums[pivot];
int i = l - 1;
int j = r + 1;
while(i < j) {
// x 不能用 nums[pivot]代替,因为 swap 会破坏 nums[pivot]
while(nums[++i] < x);
while(nums[--j] > x);
if(i < j) {
swap(nums[i], nums[j]);
}
}
quick_sort(nums, l, j);
quick_sort(nums, j+1, r);
}
```
归并排序
堆排序
(改天在学
快速选择算法
思路:直接 k-1 寻找排序后第 k-1 个元素的位置,因为每次只递归一边,所以期望复杂度时 O(n),具体证明算导(看不懂 x

``` cpp
class Solution {
public:
int findKthLargest(vector<int>& nums, int k) {
return quick_select(nums, 0, nums.size() - 1, k - 1);
}

int quick_select(vector<int>& nums, int l, int r, int k) {
if(l >= r) {
return nums[l];
}
int i = l - 1;
int j = r + 1;
// int pivot = l + rand() % (r - l + 1);
int pivot = (l + r) / 2;
// int pivot = l;
int x = nums[pivot];
while(i < j) {
while(nums[++i] > x);
while(nums[--j] < x);
if(i < j) {
swap(nums[i], nums[j]);
}
}
//
// int sl = j - l + 1;
if(k <= j) {
return quick_select(nums, l, j, k);
}
return quick_select(nums, j + 1, r, k);

}
};
```

15. 三数之和
首先排序
对于 nums[i] > 0,可以直接 break ,后面不会有符合题意的三元组
注意 i 去重,jk 在取到目标三元组也需要去重,
103. 二叉树的锯齿形层序遍历
flag 标记奇 /偶