Leetcode 简略题解 - 刷题1250 题解567

这是一篇由用户 @朱里 整理的Leetcode题解。就是我。

// This is a memo for Leetcode problem set, by user @朱里. That's me.


代码库地址:zhuli19901106/leetcode-zhuli

// Code repo can be found at zhuli19901106/leetcode-zhuli.


其中的题解部分会不定期更新。

// As the number of problems is huge, I'll keep updating this article every once in a while.


目前刷题进度为:

  • 算法 1148/1318
  • 数据库 89/108
  • shell 4/4
  • 并发 9/9

/*

Current progress for interview problems:

  • 1148/1318 for algorithms
  • 89/108 for database
  • 4/4 for shell
  • 9/9 for concurrency

*/


目前题解进度为:

  • 算法567/1318

/*

Current progress for problem reviews

  • 567/1318 for algorithms

*/


下面以题号为顺序,对每一题的题意和解法做简要描述:

// Following here is a summary of description and solution for every problem I solved:


LeetCode 简略题解 - 1~100 - 知乎专栏

LeetCode 简略题解 - 101~200 - 知乎专栏

LeetCode 简略题解 - 201~300 - 知乎专栏

LeetCode 简略题解 - 301~400 - 知乎专栏

LeetCode 简略题解 - 401~500 - 知乎专栏

LeetCode 简略题解 - 501~600 - 知乎专栏

LeetCode 简略题解 - 601~700 - 知乎专栏



目前LeetCode出新题比较频繁。鉴于付费题目需要交钱才能刷,我打算攒到一两百题再掏钱。毕竟掏了一个月的钱,一个星期就刷完了,不怎么划算。按照目前LeetCode题目的难度和质量来看,每次出新题,基本都能马上搞定,毕竟刷了几百题,也很难再有什么新花样了。

// Currently LeetCode is updating problems at a fast and steady pace. The premium problems are unlocked only after payment, so I decide to take my order when there're a hundred or two available. Basically I don't deem the price quite worth, as you usually finish them off in a week while the payment is for a month. Free problems are fine, just no surprise for me anymore after doing five hundreds of them, I guess.



有人常常花很多时间。考虑做一件事“有什么用”?你猜我怎么想,“没什么卵用”。

// People tend to waste a lot of time thinking about the meaning of everything. Know what I think? Nothing. No, none, null, void.



活着、读书、上学、工作、找个人结婚、安顿下来、放弃一切理想信仰希望、混日子、变老、等死。有意义吗?没有吗?

// Live, go to school, be young and foolish, get a job, get laid, settle down, give up your dreams, beliefs and hopes, grow up into a nobody, turn old and stubborn, wither and die. What's the point? What's not?



所有题中,有大约12题左右不是独立完成,参考了网上高手的解法。调试用脑子或者纸笔。基本不使用IDE,不编译运行。

// Among these problems, around 10 were solved after referencing clever solutions from the Internet, the rest were all solved independently. Code was debugged inside my brain or on paper. IDE or compiler were hardly involved.



总体上,代码尽量追求可读性,保证时间空间复杂度的优化,并保持风格一致。

// In general, readability is what I care more about (compared to code length). Time and space complexity are bottom line. Consistent code style is maintained at best efforts.



感觉现在面试题的难度也有种“通货膨胀”的趋势,以前的“hard”题目和现在的“medium”差不多,看来工作真是越来越难找了。

// There seems to be inflation in tech interview problems as well (AFAIK prices never go down). Those rated "medium" today are no easier than those rated "hard" in the old days. Harder to make a living, isn't it?



关于很多题为什么一句话(甚至一个词)带过,简言之就是“典型题”。因为一个经过合格训练的程序员对于两百行以内的算法代码应该有足够的代码阅读能力,以及快速适应新语言的能力。每题的Github代码足够提供参考。对于关键思路做最少的提示即可,这也是面试所能容忍的程度。超出此程度,免不了被淘汰。

// As for why most problems are walked through by a mere sentence (even a single word), simply put, they're just typical. I think a programmer with proper training should have adequate competence of code reading and adaptability to new languages. The given codes on Github are sufficient for the task of illustration. Minimal hints on the key idea is what I deem tolerable for a real interview. Beyond that, you fail.



写题解的目的只是用于备忘和加深理解,所以有没有人看并不重要。

// It's just a memo to help fortify comprehension. Ain't no big deal if nobody's reading this.



如果有人看了后,觉得我某道题的解法有值得讨论或者错误的地方,欢迎在评论里指出。

// Should anyone feel the need for discussion, please leave your comment.



以下是更新日志:

// Change logs are as follows:



截止2017年3月11日02:25,Leetcode的Algorithm部分(包括付费题目)总共491题。

// As of the moment 02:25, 2017.3.11, there're altogether 491 problems in the Algorithm section of Leetcode.



截止2017年3月23日05:02,Leetcode的Algorithm部分(包括付费题目)总共499题。

// As of the moment 05:02, 2017.3.23, there're altogether 499 problems in the Algorithm section of Leetcode.



截止2017年4月26日15:01,Leetcode的Algorithm部分(包括付费题目)总共519题。

// As of the moment 15:01, 2017.4.26, there're altogether 519 problems in the Algorithm section of Leetcode.



截止2017年5月3日11:13,Leetcode的Algorithm部分(包括付费题目)总共523题。

// As of the moment 11:13, 2017.5.3, there're altogether 523 problems in the Algorithm section of Leetcode.



截止2017年5月26日21:08,Leetcode的Algorithm部分(包括付费题目)总共535题。

// As of the moment 21:08, 2017.5.26, there're altogether 535 problems in the Algorithm section of Leetcode.



截止2017年6月10日16:52,Leetcode的Algorithm部分(包括付费题目)总共543题。

// As of the moment 16:52, 2017.6.10, there're altogether 543 problems in the Algorithm section of Leetcode.



截止2017年8月14日10:33,Leetcode的Algorithm部分(包括付费题目)总共585题。

// As of the moment 10:33, 2017.8.14, there're altogether 585 problems in the Algorithm section of Leetcode.


截止2020年3月09日15:27,Leetcode的Algorithm部分(包括付费题目)总共1264题。

// As of the moment 15:27, 2020.3.9, there're altogether 1264 problems in the Algorithm section of Leetcode.


截止2020年3月26日02:36,Leetcode的Algorithm部分(包括付费题目)总共1277题,Database部分(包括付费题目)总共102题。

// As of the moment 02:36, 2020.3.26, there're altogether 1277 problems in the Algorithm section of Leetcode, 102 problems in the Database section of Leetcode.

编辑于 2020-05-27 06:02