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
Fanlu91 commented 5 years ago

第二周题目

哈希表

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

二叉树

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

二叉搜索树

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

SherryShi0108 commented 5 years ago

学号:086 username:SherryShi0108 第二周作业链接:https://github.com/SherryShi0108/algorithm/tree/master/Week_02/id_86 学习感言:#295

songsmith commented 5 years ago

学号:137 Username:songsmith 第二周作业链接:https://github.com/songsmith/algorithm/tree/master/Week_02/id_137 学习感言: #300

suncen0505 commented 5 years ago

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

shimmer236 commented 5 years ago

学号:062 username:shimmer236 第二周作业链接:https://github.com/shimmer236/algorithm/tree/qq/Week_02/id_62 学习感言:#304

honeyaya commented 5 years ago

学号:150 username:honeyaya 第二周作业链接:https://github.com/algorithm001/algorithm/pull/305 学习感言:#null

otkinlife commented 5 years ago

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

Maybrittnelson commented 5 years ago

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

suncen0505 commented 5 years ago

学号:086 username:SherryShi0108 第二周作业链接:https://github.com/SherryShi0108/algorithm/tree/master/Week_02/id_86 学习感言:#295

我这有个疑问,就是为什么要减少return 呢?我倒觉得没必要的时候,直接return ,省去后续的处理,不是更好吗

suncen0505 commented 5 years ago

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

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

suncen0505 commented 5 years ago

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

总结的挺好的,可以多换集中解题技巧,比如我的可能是先把需要的步骤大概列出来,然后再填充临界条件,退出条件,递归条件

suncen0505 commented 5 years ago

学号:137 Username:songsmith 第二周作业链接:https://github.com/songsmith/algorithm/tree/master/Week_02/id_137 学习感言: #300

我做第一个二叉树的题的时候,也卡壳了 ,还是觉得二叉树没有屡清楚,后续慢慢把树的特征画图出来,慢慢一点一点解,发现还是挺有趣的

suncen0505 commented 5 years ago

学号:062 username:shimmer236 第二周作业链接:https://github.com/shimmer236/algorithm/tree/qq/Week_02/id_62 学习感言:#304

字符串的那个题我觉得挺好玩,我用的是hash存储,但是更优化的解题思路是 字符-a作为数组的下标,我觉得这种方法太秒了,哈哈,也可以收录到你的内容里去

jianghaoyuan2007 commented 5 years ago

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

FollowMyHeart commented 5 years ago

学号:033 Username: FollowMyHeart 第二周作业链接:https://github.com/FollowMyHeart/algorithm/tree/master/Week_02/id_33 学习感言:#316

FollowMyHeart commented 5 years ago

学号:137 Username:songsmith 第二周作业链接:https://github.com/songsmith/algorithm/tree/master/Week_02/id_137 学习感言: #300

Python语言中变量跟None比较相等是不是应该用is?

aiter commented 5 years ago

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

liutong-cnu commented 5 years ago

学号:144 Username:liutong 第二周作业链接:https://github.com/liutong-cnu/algorithm/tree/master/Week_02/id_144 学习感言:null

IMC666 commented 5 years ago

学号:082 Username:IMC666 第二周作业链接:https://github.com/IMC666/algorithm/tree/1f6a3c49e18c16cf273a9a90850d8f8228c570a9/Week_01/id_82/%E4%BA%8C%E5%8F%89%E6%A0%91 学习感言:#321

AHaoPang commented 5 years ago

学号:009 Username:AHaoPang 第二周作业链接:https://github.com/AHaoPang/algorithm/tree/master/Week_02/id_9 学习感言:#323

zouyingjie commented 5 years ago

学号:001 Username:zouyingjie 第二周作业链接:https://github.com/zouyingjie/algorithm/tree/master/Week_02/id_1 学习感言:#324

v1xingyue commented 5 years ago
yuanyunxu commented 5 years ago

学号: 122 UserName : yuanyunxu 第二周作业链接:https://github.com/yuanyunxu/algorithm/tree/master/Week_02/id_122 学习总结: https://github.com/algorithm001/algorithm/issues/329

yxs354 commented 5 years ago

学号: 044 UserName : yxs354 第二周作业链接:https://github.com/yxs354/algorithm/tree/master/Week_02/id_44 学习总结: #330

HongChao6 commented 5 years ago

学号:137 Username:songsmith 第二周作业链接:https://github.com/songsmith/algorithm/tree/master/Week_02/id_137 学习感言: #300

Python语言中变量跟None比较相等是不是应该用is?

== 是对内容的判断; is 是对 id 的判断 Python 中所有的 None 值的 id 都是一样的

用 is 会更好一些,速度比 == 要快,因为 == 要运行查找和比较函数

HongChao6 commented 5 years ago

学号:086 username:SherryShi0108 第二周作业链接:https://github.com/SherryShi0108/algorithm/tree/master/Week_02/id_86 学习感言:#295

看到你用 python 写的 '242.有效的字母异位词' 第二种方法是 调用排序函数 然后直接判断相等,不禁感叹前人栽树 后人乘凉 671题,可以考虑将 '最小值' 这个参数去掉,减少一点空间;方式:给PDFS函数增加第二个参数minVal(引用形式),然后将 root.val 最为初始值传入

HongChao6 commented 5 years ago

学号:137 Username:songsmith 第二周作业链接:https://github.com/songsmith/algorithm/tree/master/Week_02/id_137 学习感言: #300

你这不是在LeetCode上做的吧,创建了256个空间的数组,在比较字母种类不多的情况下,变成稀疏数组了,且 题目中只要求比较小写字母,你用26个空间的数组即可

HongChao6 commented 5 years ago

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

从二叉树中找到 第二小值 的节点 题,我是创建了一个私有变量用于保存第二小的值

HongChao6 commented 5 years ago

学号:062 username:shimmer236 第二周作业链接:https://github.com/shimmer236/algorithm/tree/qq/Week_02/id_62 学习感言:#304

你用C编的题 变量 都是 i j k s 看着好费劲啊,希望写点注释,让别人去读代码,而不是理解代码

HongChao6 commented 5 years ago

学号: 044 UserName : yxs354 第二周作业链接:https://github.com/yxs354/algorithm/tree/master/Week_02/id_44 学习总结: #330

没学过 java ,能说一下使用 PriorityQueue 结构 的用意跟用法么

GradyWong commented 5 years ago

学号:069 username:GradyWong 第二周作业链接:https://github.com/GradyWong/algorithm/tree/master/Week_02/id_69 学习感言:https://github.com/algorithm001/algorithm/issues/332

brokge commented 5 years ago

学号:080 username:brokge 第二周作业链接:https://github.com/brokge/algorithm/tree/master/Week_02/id_80 学习感言:#334 语言:java

ericyang89 commented 5 years ago

学号: 023 username: ericyang89 第二周作业链接:https://github.com/ericyang89/algorithm/tree/master/Week_02/id_23 学习感言:#336 语言:JavaScript

fishLite commented 5 years ago

学号:013 username : fishLite 第二周作业链接:https://github.com/fishLite/algorithm/tree/master/Week_02/id_13 学习感言:#340

Water-DD commented 5 years ago

学号:011 username : Water-DD 第二周作业链接:https://github.com/Water-DD/algorithm/tree/master/Week_02/id_11 学习感言:#341

baidulinux commented 5 years ago

学号:143 username : baidulinux 第二周作业链接:https://github.com/baidulinux/algorithm/tree/master/Week_02/id_143 学习感言:https://github.com/algorithm001/algorithm/issues/342

linear063 commented 5 years ago

学号:042 username:linear063 第二周作业链接:https://github.com/linear063/algorithm/tree/master/Week_02/id_42 学习感想:https://github.com/algorithm001/algorithm/issues/344

quanhoucun commented 5 years ago

学号:109 username:quanhoucun 第二周作业链接:https://github.com/quanhoucun/algorithm/tree/master/Week_02/id_109 学习感言:#346

luckypeak commented 5 years ago

学号:124 username:luckypeak 第二周作业链接:https://github.com/luckypeak/algorithm/tree/master/Week_02/id_124 学习感言:https://github.com/algorithm001/algorithm/issues/350

361028096 commented 5 years ago

学号:053 username:361028096 第二周作业链接:https://github.com/361028096/algorithm/tree/master/Week_02/id_53 学习感言:#353

xuyunbo commented 5 years ago

学号:090 username:xuyunbo 第二周作业链接:https://github.com/algorithm001/algorithm/tree/master/Week_02/id_90 学习感言:#356

tidelgl commented 5 years ago

学号:064 Username:李路 第一周作业链接(JavaScript):https://github.com/tidelgl/algorithm/tree/week-2/Week_02/id_64 学习感言:https://github.com/algorithm001/algorithm/issues/358

daodaoshao commented 5 years ago

学号:084 Username:daodaoshao 第二周作业链接:https://github.com/daodaoshao/algorithm/tree/master/Week_02/id_84 学习总结:#361

hotboy commented 5 years ago

学号:034 Username:hotboy(王文帅) 第二周作业链接:https://github.com/hotboy/algorithm/tree/master/Week_02/id_34 学习总结:https://github.com/algorithm001/algorithm/issues/362

salanhess commented 5 years ago

学号:040 username:salanhess 第二周作业链接: golang版 https://github.com/salanhess/algorithm/tree/master/Week_02/id_40 学习感言:https://github.com/algorithm001/algorithm/issues/364

sadcat commented 5 years ago

学号:113 username:sadcat 第二周作业链接:https://github.com/algorithm001/algorithm/pull/366 学习感言:https://github.com/algorithm001/algorithm/issues/365

bitwei commented 5 years ago

学号:099 username:bitwei 第二周作业链接:https://github.com/bitwei/algorithm/tree/master/Week_02/id_99 学习感言:#367

bitwei commented 5 years ago

学号:053 username:361028096 第二周作业链接:https://github.com/361028096/algorithm/tree/master/Week_02/id_53 学习感言:#353

242使用java语言的排序不是最优的解法 671需要首先对TreeNode做判空处理

kk5171 commented 5 years ago

学号:119 username:kk5171 第二周作业链接:https://github.com/kk5171/algorithm/tree/master/Week_02/id_119 学习感言:#370

myrichhub commented 5 years ago

学号:028 username:myrichhub 第二周作业链接:https://github.com/myrichhub/algorithm/tree/master/Week_02/id_28 学习感言:[总结](【028-Week2】学习总结 #369)