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

推荐订阅源

W
WeLiveSecurity
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
Stack Overflow Blog
Stack Overflow Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
Cloudbric
Cloudbric
The Register - Security
The Register - Security
小众软件
小众软件
PCI Perspectives
PCI Perspectives
G
Google Developers Blog
AI
AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google DeepMind News
Google DeepMind News
Google DeepMind News
Google DeepMind News
宝玉的分享
宝玉的分享
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
TaoSecurity Blog
TaoSecurity Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
F
Full Disclosure
N
Netflix TechBlog - Medium
博客园_首页
Last Week in AI
Last Week in AI
A
Arctic Wolf
B
Blog RSS Feed
J
Java Code Geeks
C
Cybersecurity and Infrastructure Security Agency CISA
I
InfoQ
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
NISL@THU
NISL@THU
MyScale Blog
MyScale Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Jina AI
Jina AI
有赞技术团队
有赞技术团队
S
Schneier on Security
L
Lohrmann on Cybersecurity
P
Privacy & Cybersecurity Law Blog
T
Threat Research - Cisco Blogs
P
Palo Alto Networks Blog
S
Security @ Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
Security Latest
Security Latest
Vercel News
Vercel News
博客园 - 司徒正美
Webroot Blog
Webroot Blog
Hacker News: Ask HN
Hacker News: Ask HN
A
About on SuperTechFans

Go Further

【教程】manim动画制作工具 【直观算法】二叉搜索树算法总结 【直观算法】二叉树遍历算法总结 【直观算法】Egg Puzzle 鸡蛋难题 博客文章总目录 TensorSpace 一个3D神经网络可视化框架 【直观详解】通俗易懂了解什么是黎曼猜想 支持币与去中心化商业模式 那些值得一看的TED演讲附全文文稿笔记 【区块链】共识算法与如何解决拜占庭将军问题 【直观详解】让你永远忘不了的傅里叶变换解析 【直观详解】泰勒级数 微信跳一跳解题报告 Dota2-A帐效果 深入浅出看懂AlphaGo Zero/AlphaGo元 【直观详解】线性代数中的转置正交正规正定 程序员技能图谱 【直观详解】线性代数的本质 【直观详解】什么是PCA、SVD 【直观详解】什么是正则化 Pandas-Wiki 【区块链】比特币与金融、ICO和监管 【区块链】现代区块链与新技术 【区块链】一文看懂区块链:一步一步发明比特币 【直观详解】拉格朗日乘法和KKT条件 【直观详解】支持向量机SVM Dota2伤害类型详解 【直观详解】机器学习分类器性能指标详解 【直观详解】信息熵、交叉熵和相对熵 Dota2机制总结 【直观详解】Logistic Regression Xpath-Wiki PDF复制粘贴去除多余的回车符 幕布-全平台笔记思维导图工具 深入浅出看懂AlphaGo如何下棋 【摘抄】清欢 - 林清玄 English-abbreviation 【原创】有关中国诗的那些事
LeetcodeNote
2017-07-01 · via Go Further

LeetcodeNote

算法培训课程基本模型汇总笔记

线

基本模型

数学归纳法

基本模板

  • Draw/Equation -> Tree shape
  • Define TreeNode
    • 本点信息必然是辅助变量,计入TreeNode
    • 孩子信息决定TreeNode的形状
    • 任何第一次走的节点,如果不能走,一定要画出来打一把叉
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Public int func(T[] array, V tartget ){
int pos = -1;
int start = 0;
int end array.length - 1;
while ( start <= end ){
int mid = start + (end - start)/2;
if ( f(a[mid]) <= target ){
pos = mid;
start = mid + 1;
} else {
end = mid - 1;
}
}
return pos;
}

Bottom up - Recursion

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public <T_P> func(T_v_1, v1 …){
checkhastreeNode();
return helper(root(T_v_1, v_1, …))
}

private <T_P> helper(T_v_1, v1, …){
resultchildfirst = helper(childFirst);

resultchildlast = helper(childLast);

-> result by childs


return result;
}

DFS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public class DFSTree {
public Type_R func(T_1, e1, T_2, e2){
checkrootexists();

TreeNode[] array = new TreeNode[TREE_HEIGHT];

Stack<TreeNode> stack = Stack<>();
stack.push(root);
while (!stack.Empty()){
TreeNode curNode = stack.pop();

Operation at node;

stack.push(childLast);

stack.push(childFirst);
}

return result;
}

private class TreeNode{
T_V_1 field_1;

T_V_q field_q;

int _height;
}

BFS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public class BFS {
public TypeR func(T_1 v_1, T_p, v_p) {
checkexistroot();

Queue<TreeNode> queue = new LinkedList<>();
queue.add(root);

while ( !queue.isEmpty() ){

int size = queue.size();
for ( int I = 0; I < size; i++ ){
TreeNode node = queue.remove();

op at node;

queue.add(childFirst);

queue.add(childLast);
}

update var_l,…,var_k for next level
}

return result;

}

private class TreeNode{
T_1 field_1;

}
}

基本模板