Open GeekUniversity opened 5 years ago
学号:024 Username: lglove(李戈) 第二周作业链接:https://github.com/lglove/algorithm/tree/master/Week_02/id_24 学习总结:#373
学号: 044 UserName : yxs354 第二周作业链接:https://github.com/yxs354/algorithm/tree/master/Week_02/id_44 学习总结: #330
没学过 java ,能说一下使用 PriorityQueue 结构 的用意跟用法么
用PriorityQueue主要还是用来统计完词频后,对单词的排序。主要还是利用优先队列内部使用堆的实现,可以构造大顶堆,top k,就从堆顶取k次。
//优先队列的比较器,先比较词频,相等的话再比较word字符串
PriorityQueue<Map.Entry<String, Integer>> pp = new PriorityQueue<>((x, y) -> {
if (x.getValue() < y.getValue()) return 1;
else if (x.getValue() > y.getValue()) return -1;
else return x.getKey().compareTo(y.getKey());
});
不知道yxs354的这个实现,在LeetCode上实际的测试耗时如何?第一次遍历,统计词频。第一次遍历,构建大顶堆。取top k时,删除堆顶后,还需要堆化。
学号:084 Username:daodaoshao 第二周作业链接:https://github.com/daodaoshao/algorithm/tree/master/Week_02/id_84 学习总结:#361
学号:090 username:xuyunbo 第二周作业链接:https://github.com/algorithm001/algorithm/tree/master/Week_02/id_90 学习感言:#356
LeetCode_267_90.java 这题用queue存比大小的值,用stack记录遍历树时分叉时的回溯点? 看着就很烧脑,不容易想到这解法,666!
结果对吗?队列操作那里没太看明白
学号:028 username:myrichhub 第二周作业链接:https://github.com/myrichhub/algorithm/tree/master/Week_02/id_28 学习感言:[总结](【028-Week2】学习总结 #369)
map使用getOrDefault方法,优雅,是加分项啊 :) 学习总结的链接有点问题
学号:082 Username:IMC666 第二周作业链接:https://github.com/IMC666/algorithm/tree/1f6a3c49e18c16cf273a9a90850d8f8228c570a9/Week_01/id_82/%E4%BA%8C%E5%8F%89%E6%A0%91 学习感言:#321
写着267,找了半天没看到题目 :(
学号:098 Username: renzhongxing 第二周作业链接:https://github.com/renzhongxing/algorithm/tree/master/Week_02/id_98 学习感言:#375
学号:042 username:linear063 第二周作业链接:https://github.com/linear063/algorithm/tree/master/Week_02/id_42 学习感想:#344
leecode_671_042.java 为啥使用TreeMap? 统计词频时,利用TreeMap按word先字母顺序排序,然后在sort部分,就只对词频排序? 哇~~~
学号:086 username:SherryShi0108 第二周作业链接:https://github.com/SherryShi0108/algorithm/tree/master/Week_02/id_86 学习感言:#295
我这有个疑问,就是为什么要减少return 呢?我倒觉得没必要的时候,直接return ,省去后续的处理,不是更好吗
这好像是C语言的遗留问题,没有RAII或其他自动内存管理那么必须要清理每次返回,所以要有尽量少的return。但是针对于C#或其他自动管理内存的语言就可以只看可读性。代码大全上17.1讲在增加可读性上可以使用多个return。
但是我的理解是单个return可以便于理解调试,而且如果需要过多return的话那说明这个方法可以重构更小更通用更易理解的方法。
对这个问题没有找到一个固定的标准答案,在Stackoverflow上有讨论,可以参考一下。
学号:014 Username: aiter 第二周作业链接(java):https://github.com/aiter/algorithm/tree/master/Week_02/id_14 学习感言: #318
看了大佬的学习总结,觉得对二叉树的总结非常全面。有很多之前我没有想到过的点
学号:028 username:myrichhub 第二周作业链接:https://github.com/myrichhub/algorithm/tree/master/Week_02/id_28 学习感言:[总结](【028-Week2】学习总结 #369)
如果code的注释多一点就更好了。阅读代码的时候能更容易理解一点
学号:064 Username:李路 第一周作业链接(JavaScript):https://github.com/tidelgl/algorithm/tree/week-2/Week_02/id_64 学习感言:#358
是JS本身的特性吗,为什么map要用const关键字呢?
了解了,多谢 用 PriorityQueue 实现的确很方便,跟你想的一样,我也怀疑耗时如何
liuhongchao_00@126.com
发件人: aiter 发送时间: 2019-04-28 07:16 收件人: algorithm001/algorithm 抄送: 红桃六; Comment 主题: Re: [algorithm001/algorithm] 算法训练营第二周作业 (#52) 学号: 044 UserName : yxs354 第二周作业链接:https://github.com/yxs354/algorithm/tree/master/Week_02/id_44 学习总结: #330 没学过 java ,能说一下使用 PriorityQueue 结构 的用意跟用法么 用PriorityQueue主要还是用来统计完词频后,对单词的排序。主要还是利用优先队列内部使用堆的实现,可以构造大顶堆,top k,就从堆顶取k次。 //优先队列的比较器,先比较词频,相等的话再比较word字符串 PriorityQueue<Map.Entry<String, Integer>> pp = new PriorityQueue<>((x, y) -> { if (x.getValue() < y.getValue()) return 1; else if (x.getValue() > y.getValue()) return -1; else return x.getKey().compareTo(y.getKey()); });
不知道yxs354的这个实现,在LeetCode上实际的测试耗时如何?第一次遍历,统计词频。第一次遍历,构建大顶堆。取top k时,删除堆顶后,还需要堆化。 — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
学号:062 username:shimmer236 第二周作业链接:https://github.com/shimmer236/algorithm/tree/qq/Week_02/id_62 学习感言:#304
总结的很细致,到位。之前对于闲散列和开散列并没有概念。学习一下
的确,不限制 return 的使用 但,一定要保证代码的可读性高,必须让别人去读代码 比让别人去理解代码 更优雅
liuhongchao_00@126.com
发件人: SherryShi0108 发送时间: 2019-04-28 09:11 收件人: algorithm001/algorithm 抄送: 红桃六; Comment 主题: Re: [algorithm001/algorithm] 算法训练营第二周作业 (#52) 学号:086 username:SherryShi0108 第二周作业链接:https://github.com/SherryShi0108/algorithm/tree/master/Week_02/id_86 学习感言:#295 我这有个疑问,就是为什么要减少return 呢?我倒觉得没必要的时候,直接return ,省去后续的处理,不是更好吗 这好像是C语言的遗留问题,没有RAII或其他自动内存管理那么必须要清理每次返回,所以要有尽量少的return。但是针对于C#或其他自动管理内存的语言就可以只看可读性。代码大全上17.1讲在增加可读性上可以使用多个return。 但是我的理解是单个return可以便于理解调试,而且如果需要过多return的话那说明这个方法可以重构更小更通用更易理解的方法。 对这个问题没有找到一个固定的标准答案,在Stackoverflow上有讨论,可以参考一下。 — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
赞同
如何写出一个优雅的、具有可读性的代码 是我们所要考虑的事情
让写代码变成一个艺术工作
liuhongchao_00@126.com
发件人: aiter 发送时间: 2019-04-28 07:47 收件人: algorithm001/algorithm 抄送: 红桃六; Comment 主题: Re: [algorithm001/algorithm] 算法训练营第二周作业 (#52) 学号:028 username:myrichhub 第二周作业链接:https://github.com/myrichhub/algorithm/tree/master/Week_02/id_28 学习感言:[总结](【028-Week2】学习总结 #369) map使用getOrDefault方法,优雅,是加分项啊 :) 学习总结的链接有点问题 — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
学号:013 username : fishLite 第二周作业链接:https://github.com/fishLite/algorithm/tree/master/Week_02/id_13 学习感言:#340
学号:013 username : fishLite 第二周作业链接:https://github.com/fishLite/algorithm/tree/master/Week_02/id_13 学习感言:#340
学号:135 username : oxcz 第二周作业链接:https://github.com/oxcz/algorithm/tree/master/Week_02/id_135 学习感言:#339
学号: 067 UserName:yulongz 第一周作业链接:https://github.com/yulongz/algorithm/tree/master/Week_02/id_67 学习感言 #376 语言: Java
学号:036 UserName:Lugyedo 第二周作业链接:https://github.com/Lugyedo/algorithm/tree/master/Week_02/id_36 学习感言:https://github.com/algorithm001/algorithm/issues/379
学号:026 UserName:Fanlu91 第二周作业链接:https://github.com/Fanlu91/algorithm/tree/master/Week_02/id_26 学习感言:https://github.com/algorithm001/algorithm/issues/380
学号:117
Username:hapiman(彭建)
第二周作业链接:https://github.com/hapiman/algorithm/tree/master/Week_02/id_117
学习感言:https://github.com/algorithm001/algorithm/issues/384
编程语言: Golang
学号: 030 UserName:GUOSF 第一周作业链接:https://github.com/GUOSF/algorithm/tree/master/Week_02/id_30 学习感言 https://github.com/algorithm001/algorithm/issues/386 语言: Java
学号: 123 UserName:zhaowende 第一周作业链接:https://github.com/zhaowende/algorithm/tree/master/Week_02/id_123 学习感言 #387
学号:141 username: smz198181 第二周作业链接:https://github.com/smz198181/algorithm/tree/master/Week_02/id_141 学习感言:#388
学号:027 username:zjg23 第二周作业链接:https://github.com/zjg23/algorithm/tree/master/Week_02/id_27 学习感言: #391
学号:108 UserName:SeanMrLi 第二周作业链接:https://github.com/SeanMrLi/algorithm/tree/master/Week_02/id_108 学习感言:https://github.com/algorithm001/algorithm/issues/392
学号:002 username:cwbcheng 第二周作业链接:https://github.com/cwbcheng/algorithm/tree/master/Week_02/id_2 学习感言: #393
学号: 039, GitHub Username: plin005(林媛媛) 第二周作业链接:https://github.com/plin005/algorithm/tree/master/Week_02/id_39 学习感言: 【039-week2】学习总结”,#394
学号:061 username:otkinlife(贾凯超) 第二周作业链接:https://github.com/otkinlife/algorithm/tree/master/Week_02/id_61 学习感言:#307
783: 递归求解,然后再用两层循环应该是时间复杂度最大,可否直接找到最小值及最大值
学号:135 username : oxcz 第二周作业链接:https://github.com/oxcz/algorithm/tree/master/Week_02/id_135 学习感言:#339
学号:097 username: alxjerr 第二周作业连接:https://github.com/alxjerr/algorithm/tree/master/Week_02/id_97 学习感言:https://github.com/algorithm001/algorithm/issues/400
学号: 039, GitHub Username: plin005(林媛媛) 第二周作业链接:https://github.com/plin005/algorithm/tree/master/Week_02/id_39 学习感言: 【039-week2】学习总结”,#394
学号:131 username:HongChao6 第二周作业链接:https://github.com/HongChao6/algorithm/tree/master/Week_02/id_131 学习感言:#310
学号:016 username:ajun 第二周作业链接:https://github.com/ajun-victor/algorithm/tree/master/Week_02/id_16 学习感言:#null 代码语言:Java
学号: 123 UserName:zhaowende 第一周作业链接:https://github.com/zhaowende/algorithm/tree/master/Week_02/id_123 学习感言 #387
783: 测试case学习了
学号:129 username:zsndev 第二周作业链接:https://github.com/zsndev/algorithm/tree/master/Week_02/id_129 学习感言:#406 代码语言:Java
学号: 100 UserName:bin_albin 第一周作业链接:https://github.com/bin-albin/algorithm/tree/master/Week_02/id_100 学习感言 #407
学号:036 UserName:Lugyedo 第二周作业链接:https://github.com/Lugyedo/algorithm/tree/master/Week_02/id_36 学习感言:#379
242题最后的那个遍历可以省掉,在循环参数t的时候,其实只要发现值小于等于0就可以return false了
学号:087 username:gebitang 第二周作业链接:https://github.com/gebitang/algorithm/tree/master/Week_02/id_87 学习感言:#409 代码语言:Java
学号:135 username : oxcz 第二周作业链接:https://github.com/oxcz/algorithm/tree/master/Week_02/id_135 学习感言:#339
692题使用优先级队列排序的时候,把所有数据一次性都加进去了,空间复杂度一下多了o(n),可以只维护大小为k的优先级队列
学号:102 username:speng975 第二周作业链接:https://github.com/speng975/algorithm/tree/master/Week_02/id_102 学习感言:#408
学号:087 username:gebitang 第二周作业链接:https://github.com/gebitang/algorithm/tree/master/Week_02/id_87 学习感言:#409 代码语言:Java
692题, map有个叫getOrDefault的方法可以简化一开始扫描的代码,不用再写额外的if else了。 另外取topK那块儿,在大家普遍用系统库的情况下,你从头撸了个链表也是挺给力的
学号:085 username : MrMuddle 第二周作业链接:https://github.com/MrMuddle/algorithm/tree/master/Week_02/id_85 学习感言:#411
学号:049 Username:bugcodes 第二周作业链接:https://github.com/bugcodes/algorithm/tree/master/Week_02/id_49 学习感言: #416
学号: 044 UserName : yxs354 第二周作业链接:https://github.com/yxs354/algorithm/tree/master/Week_02/id_44 学习总结: #330
没学过 java ,能说一下使用 PriorityQueue 结构 的用意跟用法么
学习一下。 这个PriorityQueue类库还没用过呢。
学号:101 username:gaoshengnan(seina笙南) 第二周作业链接:https://github.com/gaoshengnan/algorithm-1/tree/master/Week_02/id_101 学习总结:https://github.com/algorithm001/algorithm/issues/418
学号:102 username:speng975 第二周作业链接:https://github.com/algorithm001/algorithm/tree/master/Week_02/id_102 学习感言:#408
671题,这个题中的一定是大于等于父节点的,那解答里寻找比secondMinVal小的值,在第一次赋值后,今后就没用了吧,感觉这个条件是不是可以省掉,在树的两侧第一次给secondMinVal赋值后,不再赋值就好了
本周重点学习知识点
跳表、散列表、哈希算法、二叉树、红黑树
要求
注意事项
第二周题目
哈希表
简单: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/
作业提交规则