algorithm001 / algorithm

119 stars 152 forks source link

算法训练营第二周作业 #52

Open GeekUniversity opened 5 years ago

GeekUniversity commented 5 years ago

本周重点学习知识点

跳表、散列表、哈希算法、二叉树、红黑树

要求

  1. 每周至少完成给定题目中的两道算法题
  2. 围绕每周重点学习的算法知识点,撰写一篇有观点和思考的技术文章(字数不限)

注意事项

  1. 下面列出的题目中,按照知识点进行了简单分类,但并不意味着使用相应的数据结构或算法一定是解决该题目的最优解,这样分类只是为了方便大家有针对性的练习;
  2. 有的题目可能需要结合多个算法或数据结构进行求解。

第二周题目

哈希表

简单:https://leetcode-cn.com/problems/valid-anagram/ 中等:https://leetcode-cn.com/problems/top-k-frequent-words 中等:https://leetcode-cn.com/problems/find-duplicate-file-in-system/ 困难:https://leetcode-cn.com/problems/substring-with-concatenation-of-all-words/ 困难:https://leetcode-cn.com/problems/number-of-atoms/

二叉树

简单:https://leetcode-cn.com/problems/second-minimum-node-in-a-binary-tree/ 中等:https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-tree/ 中等:https://leetcode-cn.com/problems/all-nodes-distance-k-in-binary-tree/ 困难:https://leetcode-cn.com/problems/count-of-smaller-numbers-after-self/ 困难:https://leetcode-cn.com/problems/binary-tree-maximum-path-sum/

二叉搜索树

简单:https://leetcode-cn.com/problems/minimum-distance-between-bst-nodes/ 中等:https://leetcode-cn.com/problems/range-sum-of-bst/ 中等:https://leetcode-cn.com/problems/contains-duplicate-iii/ 困难:https://leetcode-cn.com/problems/count-of-range-sum/ 困难:https://leetcode-cn.com/problems/count-of-smaller-numbers-after-self/

作业提交规则

  1. 在提交作业之前,请先阅读这里的 README 文档:https://github.com/algorithm001/algorithm/blob/master/README.md
  2. 然后在此 Issues 下按照如下格式回复:
  1. 学号 + GitHub Username
  2. 作业代码的 GitHub 链接(填写自己仓库下对应的作业链接即可,同时记得给本仓库提交 pull request)
  3. 发表自己本周的学习感言 issues,并提交链接,issues 标题格式:“【学号后三位-week2】+文章标题”,格式参考:https://github.com/algorithm001/algorithm/issues/9
shironghui0593 commented 5 years ago

学号:065 username:shironghui0593 第二周作业链接:https://github.com/shironghui0593/algorithm/tree/master/Week_02/id_65 学习感言:#420

gaoshengnan commented 5 years ago

, 放大 发d r

总结的很好呀,学习到了~

gaoshengnan commented 5 years ago

学号:049 Username:bugcodes 第二周作业链接:https://github.com/bugcodes/algorithm/tree/master/Week_02/id_49 学习感言: #416

坚持练习LeetCode,加油!

JackZhangDF commented 5 years ago

学号:010 username:JackZhangDF 第二周作业链接:https://github.com/JackZhangDF/algorithm/tree/master/Week_02/id_10 学习感言:#421

yanlingli3799 commented 5 years ago

学号:118,姓名:李颜翎 第二周作业链接:https://github.com/yanlingli3799/algorithm/tree/master/Week_02/id_118 学习感言:https://github.com/algorithm001/algorithm/issues/415 题目列表:236、242、671、692、863

xiangfeifei54 commented 5 years ago

学号:077 username:xiangfeifei 作业:id_77 学习感言:【077-week2】第二周学习总结

xxd commented 5 years ago
  1. 学号:055 Username:xxd
  2. 第二周作业链接:https://github.com/xxd/algorithm/tree/055/Week_02/id_55
  3. 学习感言:【55-week2】总结 #422
DevinSu commented 5 years ago

学号:126 Username:suncen0505 第二周作业链接:https://github.com/suncen0505/algorithm/tree/master/Week_02/id_126 学习感言: #302

用map确实会多处理一些特殊情况,最关键是 存储的是对象 Integer是null 思路是一样的,数组更简洁明了

dreakzss commented 5 years ago

学号:139 username:dreakzss 第二周作业链接:https://github.com/dreakzss/algorithm/tree/master/Week_02/id_139 学习总结:https://github.com/algorithm001/algorithm/issues/426

DevinSu commented 5 years ago

学号:049 Username:bugcodes 第二周作业链接:https://github.com/bugcodes/algorithm/tree/master/Week_02/id_49 学习感言: #416

总结里的二叉树遍历 再用非递归实现一遍会更好

DevinSu commented 5 years ago

学号:038 Username:jianghaoyuan2007 第一周作业链接:https://github.com/jianghaoyuan2007/algorithm/tree/master/Week_02/id_38 学习感言: #311

总结的很细致,画了8种情况/👍

defuncc commented 5 years ago

学号:019 username:defuncc 第二周作业链接:https://github.com/defuncc/algorithm/tree/master/Week_02/id_19 学习感言:#429

yanlingli3799 commented 5 years ago

学号:126 Username:suncen0505 第二周作业链接:https://github.com/suncen0505/algorithm/tree/master/Week_02/id_126 学习感言: #302

先按自己的思路做出来就已经很好了。然后再去思考有没有其他的解法,或者review一下别人的解法。不必上来就奔着就最高效率的目标去,过程有时候比结果重要~

DevinSu commented 5 years ago

学号:108 UserName:SeanMrLi 第二周作业链接:https://github.com/SeanMrLi/algorithm/tree/master/Week_02/id_108 学习感言:#392

用了多种解法解题很棒,第一个用map解会比直接用数组考虑更多

sqrtqiezi commented 5 years ago

学号:021 Username:sqrtqiezi 第二周作业链接:https://github.com/sqrtqiezi/algorithm/tree/master/Week_02/id_21 学习感言:#430

DevinSu commented 5 years ago

学号: 039, GitHub Username: plin005(林媛媛) 第二周作业链接:https://github.com/plin005/algorithm/tree/master/Week_02/id_39 学习感言: 【039-week2】学习总结”,#394

代码多一点注释会更好,继续加油

DevinSu commented 5 years ago

学号:097 username: alxjerr 第二周作业连接:https://github.com/alxjerr/algorithm/tree/master/Week_02/id_97 学习感言:#400

有自己的思考,为你点赞

zsndev commented 5 years ago

学号:118,姓名:李颜翎 第二周作业链接:https://github.com/yanlingli3799/algorithm/tree/master/Week_02/id_118 学习感言:#415 题目列表:236、242、671、692、863

242题,虽然数组可以算是最简单的map,但数组起名叫hashMap,一下给看懵了(一开始跳着看的),个人觉得类型是数组的,还是叫array之类的,辨识度高的比较好吧

yanlingli3799 commented 5 years ago

学号:038 Username:jianghaoyuan2007 第一周作业链接:https://github.com/jianghaoyuan2007/algorithm/tree/master/Week_02/id_38 学习感言: #311

671 这道题,其实是可以理解成一个特殊的“小顶堆”的(像你开始想的那样,类似一个小顶堆,但不限制是否为完全二叉树),特点是:每棵子树根节点都是整个子树中的最小节点。这样,要找第二小的话,情况其实不多,枚举下来也就4种,我觉得你可以照着这个思路继续想想,一定能想出一个其他的解题方案的。

yanlingli3799 commented 5 years ago

学号:118,姓名:李颜翎 第二周作业链接:https://github.com/yanlingli3799/algorithm/tree/master/Week_02/id_118 学习感言:#415 题目列表:236、242、671、692、863

242题,虽然数组可以算是最简单的map,但数组起名叫hashMap,一下给看懵了(一开始跳着看的),个人觉得类型是数组的,还是叫array之类的,辨识度高的比较好吧

同学说的有道理~ 不过,在这里,这个数组就是当哈希表用的哦,下标当key,其值是value,所以我觉得这么命名也是可以的,名字直接指代其用途~

AlenPark commented 5 years ago

学号:072 Username:AllenPark 第二周作业链接:https://github.com/AlenPark/algorithm/tree/master/Week_02/id_72 学习感言: #433

wangfanstar commented 5 years ago

学号:057 username:wangfanstar 第二周作业链接:https://github.com/wangfanstar/algorithm/tree/057-wangfan/Week_02/id_57 学习感言:https://github.com/algorithm001/algorithm/issues/432

rononz commented 5 years ago

学号:142 username:rononz 第二周作业链接:https://github.com/rononz/algorithm/tree/master/Week_02/id_142 学习感言: https://github.com/algorithm001/algorithm/issues/434

yimeng commented 5 years ago

学号:128 username:yimeng 第二周作业链接:https://github.com/yimeng/algorithm/tree/master/Week_02/id_128 学习感言:#438

glve1027 commented 5 years ago

学号:031 username:Glve1027 第二周作业链接:https://github.com/glve1027/algorithm/tree/master/Week_02/id_31 学习感言: #437 语言:Swift

yanlingli3799 commented 5 years ago

学号:010 username:JackZhangDF 第二周作业链接:https://github.com/JackZhangDF/algorithm/tree/master/Week_02/id_10 学习感言:#421

赞,top K 问题确实通用思路就是堆排,我是直接奔着哈希表去了,麻烦的很,不用库函数的话还得自己写字典序排序~

haotone commented 5 years ago

学号:015 username:haotone 第二周作业链接:https://github.com/haotone/algorithm/tree/master/Week_02/id_15 学习感言: #436

yanlingli3799 commented 5 years ago

学号:142 username:rononz 第二周作业链接:https://github.com/rononz/algorithm/tree/master/Week_02/id_142 学习感言: #434

赞,向你学习,多去看看源码,理论结合实践。

tolookme commented 5 years ago

学号:078 Username:tolookme 第一周作业链接:https://github.com/tolookme/algorithm/tree/master/Week_02/id_78 学习感言:#440

tommy1989 commented 5 years ago

学号:075 Username:tommy1989 第二周作业链接:https://github.com/tommy1989/algorithm/tree/master/Week_02/id_75 学习感言:https://github.com/algorithm001/algorithm/issues/441

yanlingli3799 commented 5 years ago

学号:049 Username:bugcodes 第二周作业链接:https://github.com/bugcodes/algorithm/tree/master/Week_02/id_49 学习感言: #416

还原二叉树这个问题,大学的时候没少做,回去复习了~

570035853 commented 5 years ago

学号:029 username:570035853 第二周作业链接:https://github.com/570035853/algorithm/tree/master/Week_02/id_29 学习感言: #439

wcvolcano commented 5 years ago

学号:047 username:wcvolcano 第二周作业链接:https://github.com/wcvolcano/algorithm/tree/master/Week_02/id_47 学习感言:#444

haotone commented 5 years ago

学号:142 username:rononz 第二周作业链接:https://github.com/rononz/algorithm/tree/master/Week_02/id_142 学习感言: #434 第一映像,代码简洁干净。自己的代码还是不够简洁。思路较自己的更清晰。用了数组辅助算法,以每个字符与‘a’的差做下标,值为出现次数。简单清晰,值得学习。

guwunianzhi commented 5 years ago

学号:133 username:guwunianzhi 第二周作业链接:https://github.com/guwunianzhi/algorithm/tree/master/Week_02/id_133 学习感言:#445

GUOSF commented 5 years ago

学号:014 Username: aiter 第二周作业链接(java):https://github.com/aiter/algorithm/tree/master/Week_02/id_14 学习感言: #318 topK一般用小顶堆或大顶堆,代码少点。

MrQingQuan commented 5 years ago

学号:133 username:MrQingQuan 第二周作业链接:https://github.com/MrQingQuan/algorithm/tree/master/Week_02/id_46 学习感言:#442

tolookme commented 5 years ago

学号:061 username:otkinlife(贾凯超) 第二周作业链接:https://github.com/otkinlife/algorithm/tree/master/Week_02/id_61 学习感言:#307

总结的太好了。

wangxu0 commented 5 years ago

学号:134 username:wxisme 第二周作业链接:https://github.com/wxisme/algorithm/tree/master/Week_02/id_134 学习总结:https://github.com/algorithm001/algorithm/issues/449

haotone commented 5 years ago

学号:075 Username:tommy1989 第二周作业链接:https://github.com/tommy1989/algorithm/tree/master/Week_02/id_75 学习感言:#441

242 与上一位的思路类似。只是在第二次遍历时,添加判断为零返回false,更简洁。

wangxu0 commented 5 years ago

学号:061 username:otkinlife(贾凯超) 第二周作业链接:https://github.com/otkinlife/algorithm/tree/master/Week_02/id_61 学习感言:#307 赞

jonjia commented 5 years ago

学号:130 Username:jonjia 第二周作业链接:https://github.com/jonjia/algorithm/tree/master/Week_02/id_130 学习感言: #450 实现语言:JS

yanlingli3799 commented 5 years ago

赞,在学习/工作过程中,及时发现问题、提出方案并落地实践,这是我工作快一年的时候才意识到的一项非常重要的工程师能力之一。

liusuisui commented 5 years ago
haotone commented 5 years ago

学号:075 Username:tommy1989 第二周作业链接:https://github.com/tommy1989/algorithm/tree/master/Week_02/id_75 学习感言:#441 783 思路是中序遍历二叉树,收集值。相邻值做差取最小值。自己没有想到的是,一次遍历就可以取到最小值,不用排序。

GUOSF commented 5 years ago

学号:029 username:570035853 第二周作业链接:https://github.com/570035853/algorithm/tree/master/Week_02/id_29 学习感言: #439

学习了~

plin005 commented 5 years ago

学号:116 username:Maybrittnelson 第二周作业链接:https://github.com/Maybrittnelson/algorithm/tree/master/Week_02/id_116 学习感言:#308

我也做了几道树的题目,总体也是磕磕绊绊的,但是我的思路是 先把需要的步骤大概列出来,然后再填充临界条件,退出条件,递归条件

总结的精辟, 学习了l

artisticman commented 5 years ago

学号:140 username:artisticman 第二周作业链接:https://github.com/artisticman/algorithm/tree/master/Week_02/id_140 学习感言:https://github.com/algorithm001/algorithm/issues/453

GUOSF commented 5 years ago

学号:014 Username: aiter 第二周作业链接(java):https://github.com/aiter/algorithm/tree/master/Week_02/id_14 学习感言: #318

每次看你总结详细~

haotone commented 5 years ago

学号:024 Username: lglove(李戈) 第一周作业链接:https://github.com/lglove/algorithm/blob/master/Week_01/id_24/leet_code.md 学习感言:#54

242 虽然不是一个语言,但是看到了第三种方法。将字符集和排序,相等则返回true。缺点排序效率较低。