Todo所有Locked的题目的分析解答

Posted 笨鸟居士的博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Todo所有Locked的题目的分析解答相关的知识,希望对你有一定的参考价值。

 

下面这个链接有比较全的leetcode题目包括锁的

http://www.cnblogs.com/grandyang/p/4606334.html

 

https://leetcode.com/problems/binary-tree-upside-down/

http://blog.csdn.net/xudli/article/details/42362441

 

https://leetcode.com/problems/read-n-characters-given-read4/

http://blog.csdn.net/xudli/article/details/42458865

 

https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times/

http://blog.csdn.net/xudli/article/details/43225571

 

https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters/

http://blog.csdn.net/xudli/article/details/43222593

 

https://leetcode.com/problems/one-edit-distance/

http://blog.csdn.net/xudli/article/details/42340867

 

https://leetcode.com/problems/missing-ranges/

http://blog.csdn.net/yangliuy/article/details/46502541

 

https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/

http://blog.csdn.net/xudli/article/details/42290269

 

https://leetcode.com/problems/two-sum-iii-data-structure-design/

http://blog.csdn.net/xudli/article/details/42290251

 

https://leetcode.com/problems/reverse-words-in-a-string-ii/

http://www.cnblogs.com/dolphin0520/p/3700019.html

 

https://leetcode.com/problems/shortest-word-distance/

http://blog.csdn.net/xudli/article/details/48766955

 

https://leetcode.com/problems/shortest-word-distance-ii/

http://nb4799.neu.edu/wordpress/?p=1028

 

https://leetcode.com/problems/shortest-word-distance-iii/

http://www.cnblogs.com/easonliu/p/4784826.html

 

https://leetcode.com/problems/strobogrammatic-number/

http://www.cnblogs.com/grandyang/p/5196960.html

http://www.tangjikai.com/algorithms/leetcode-246-strobogrammatic-number

 

https://leetcode.com/problems/strobogrammatic-number-ii/

http://www.cnblogs.com/grandyang/p/5200919.html

http://www.cnblogs.com/airwindow/p/4804054.html

 

https://leetcode.com/problems/strobogrammatic-number-iii/

http://www.cnblogs.com/grandyang/p/5203228.html

 

https://leetcode.com/problems/group-shifted-strings/

http://www.cnblogs.com/airwindow/p/4806168.html

 

https://leetcode.com/problems/count-univalue-subtrees/

http://blog.csdn.net/pointbreak1/article/details/48998407

 

https://leetcode.com/problems/flatten-2d-vector/

http://blog.csdn.net/pointbreak1/article/details/48823513

 

https://leetcode.com/problems/meeting-rooms/

http://blog.csdn.net/sbitswc/article/details/49068503

 

https://leetcode.com/problems/meeting-rooms/

方法很好

http://blog.csdn.net/sbitswc/article/details/49068625

 

https://leetcode.com/problems/factor-combinations/

方法不错

http://www.cnblogs.com/airwindow/p/4822572.html

 

https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree/

http://www.meetqun.com/thread-10674-1-1.html (递归)

http://www.thinksaas.cn/topics/0/397/397305.html (非递归,constant space)

 

https://leetcode.com/problems/paint-house/

http://www.cnblogs.com/easonliu/p/4784858.html

 

https://leetcode.com/problems/3sum-smaller/

好题

http://www.cnblogs.com/airwindow/p/4802521.html

 

https://leetcode.com/problems/graph-valid-tree/

https://segmentfault.com/a/1190000003791051

http://blog.csdn.net/dm_vincent/article/details/7655764 (并查集)

 

https://leetcode.com/problems/paint-house-ii/

http://www.cnblogs.com/easonliu/p/4784858.html

 

https://leetcode.com/problems/palindrome-permutation/

http://www.bubuko.com/infodetail-1109927.html

http://www.cnblogs.com/anne-vista/p/4831003.html (一样的,用map或者set)

 

https://leetcode.com/problems/palindrome-permutation-ii/

http://www.cnblogs.com/airwindow/p/4806012.html

 

https://leetcode.com/problems/alien-dictionary/

好,DFS(toposort)or BFS(based on indegree)

http://www.cnblogs.com/jcliBlogger/p/4758761.html

 

https://leetcode.com/problems/closest-binary-search-tree-value/

http://www.cnblogs.com/Dylan-Java-NYC/p/5204357.html

 

https://leetcode.com/problems/encode-and-decode-strings/

利用长度,巧妙

http://www.cnblogs.com/easonliu/p/4784912.html

 

https://leetcode.com/problems/closest-binary-search-tree-value-ii/

利用堆

http://blog.csdn.net/xudli/article/details/48752907

 

https://leetcode.com/problems/paint-fence/

题目见

http://www.cnblogs.com/easonliu/p/4784886.html

更清楚的说明

https://leetcode.com/discuss/71756/explanation-of-dp-o-n-time-complexity-o-1-space-complexity

 

https://leetcode.com/problems/find-the-celebrity/

http://www.cnblogs.com/easonliu/p/4785253.html

 

https://leetcode.com/problems/wiggle-sort/

http://blog.csdn.net/xudli/article/details/48749155

 

https://leetcode.com/problems/zigzag-iterator/

http://blog.csdn.net/xudli/article/details/48749219

 

https://leetcode.com/problems/inorder-successor-in-bst/

http://www.jianshu.com/p/218f686d6494

 

https://leetcode.com/problems/walls-and-gates/

https://segmentfault.com/a/1190000003906674

 

https://leetcode.com/problems/unique-word-abbreviation/

http://blog.csdn.net/xudli/article/details/48860911

 

https://leetcode.com/problems/word-pattern-ii/

http://www.cnblogs.com/jcliBlogger/p/4870514.html

 

https://leetcode.com/problems/flip-game/

http://www.aichengxu.com/view/77156

 

https://leetcode.com/problems/flip-game-ii/

下面有题目,但是解法有bug(递归之后没有恢复)

http://www.cnblogs.com/yrbbest/p/5043682.html

正确的解法在这里:

https://leetcode.com/discuss/64344/theory-matters-from-backtracking-128ms-to-dp-0ms

 

https://leetcode.com/problems/best-meeting-point/

http://blog.csdn.net/pointbreak1/article/details/49422265

 

https://leetcode.com/problems/binary-tree-longest-consecutive-sequence/

还行

http://blog.csdn.net/xudli/article/details/49493401

 

https://leetcode.com/problems/smallest-rectangle-enclosing-black-pixels/

以下O(mn)

http://blog.csdn.net/xudli/article/details/49738267

以下O(m log n + n log m)

https://leetcode.com/discuss/68246/c-java-python-binary-search-solution-with-explanation

http://www.cnblogs.com/jcliBlogger/p/4948140.html (一样的原理)

 

https://leetcode.com/problems/number-of-islands-ii/

下面介绍了QuickFind, QuickUnion的区别

http://www.cnblogs.com/EdwardLiu/p/5087633.html

下面有路径压缩:

https://leetcode.com/discuss/69572/easiest-java-solution-with-explanations

 

https://leetcode.com/problems/range-sum-query-2d-mutable/

不错

https://segmentfault.com/a/1190000004238792

 

https://leetcode.com/problems/sparse-matrix-multiplication/ 

http://blog.csdn.net/xiaohei00000/article/details/50429791

是基于以下讨论

https://leetcode.com/discuss/71968/regular-28-ms-math-solution-6-8-lines

 

https://leetcode.com/problems/binary-tree-vertical-order-traversal/

http://blog.csdn.net/qq508618087/article/details/50760661

 

https://leetcode.com/problems/shortest-distance-from-all-buildings/

http://www.cnblogs.com/grandyang/p/5297683.html

其实是借鉴了以下,但是我还是不明白怎么保证所有都联通

https://leetcode.com/discuss/74453/36-ms-c-solution

下面的倒是验证了所有都联通

https://segmentfault.com/a/1190000004187914

 

https://leetcode.com/problems/generalized-abbreviation/

解法很多很全

http://www.cnblogs.com/grandyang/p/5261569.html

 

https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/

解法很清爽,并查集

https://segmentfault.com/a/1190000004224298

 

https://leetcode.com/problems/maximum-size-subarray-sum-equals-k/

http://blog.csdn.net/jmspan/article/details/51247447

 

https://leetcode.com/problems/largest-bst-subtree/

http://www.cnblogs.com/grandyang/p/5188938.html

 

https://leetcode.com/problems/nested-list-weight-sum/

http://www.cnblogs.com/grandyang/p/5340305.html

 

https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/

http://www.cnblogs.com/grandyang/p/5351347.html

 

https://leetcode.com/problems/moving-average-from-data-stream/

http://www.cnblogs.com/grandyang/p/5450001.html

 

https://leetcode.com/problems/design-tic-tac-toe/

解法2好

http://www.cnblogs.com/grandyang/p/5467118.html

 

https://leetcode.com/problems/android-unlock-patterns/

http://www.cnblogs.com/grandyang/p/5541012.html

 

https://leetcode.com/problems/design-snake-game/

http://www.cnblogs.com/grandyang/p/5558033.html

 

https://leetcode.com/problems/line-reflection/

http://blog.csdn.net/qq508618087/article/details/51756981

 

https://leetcode.com/problems/rearrange-string-k-distance-apart/

http://blog.csdn.net/qq508618087/article/details/51762258

 

https://leetcode.com/problems/logger-rate-limiter/

http://blog.csdn.net/jmspan/article/details/51697104

 

https://leetcode.com/problems/sort-transformed-array/

http://blog.csdn.net/qq508618087/article/details/51700774

 

https://leetcode.com/problems/bomb-enemy/

http://blog.csdn.net/qq508618087/article/details/51705806

http://blog.csdn.net/jmspan/article/details/51708425

 

https://leetcode.com/problems/design-hit-counter/

http://blog.csdn.net/jmspan/article/details/51738164

 

https://leetcode.com/problems/nested-list-weight-sum-ii/

http://blog.csdn.net/jmspan/article/details/51747784

 

https://leetcode.com/problems/find-leaves-of-binary-tree/

http://blog.csdn.net/jmspan/article/details/51760985

 

https://leetcode.com/problems/plus-one-linked-list/

http://blog.csdn.net/qq508618087/article/details/51779701

 

https://leetcode.com/problems/range-addition/

http://blog.csdn.net/jmspan/article/details/51787011 (第二种的好方法我也想到了哈哈)

 

https://leetcode.com/problems/design-phone-directory/

http://www.cnblogs.com/grandyang/p/5735205.html

 

https://leetcode.com/problems/valid-word-abbreviation

http://www.cnblogs.com/grandyang/p/5930369.html

本身题目比较简单,但是文章最后提到的前面那道 Generalized Abbreviation的解法却非常有意思:

http://www.cnblogs.com/grandyang/p/5261569.html

另外看到一个好的解法:

即把"i12iz4n"这样的缩写转换成"i.{12}iz.{4}n"

1     public boolean validWordAbbreviation(String word, String abbr) {
2         return word.matches(abbr.replaceAll("[1-9]\\\\d*", ".{$0}"));
3     }

 

https://leetcode.com/problems/minimum-unique-word-abbreviation

http://www.cnblogs.com/grandyang/p/5935836.html

解法一般,用缩写去轮询比较。

http://www.cnblogs.com/easonliu/p/4852129.html

这里的方法稍好一些,通过Hashmap来存储abbreviation.

 

https://leetcode.com/problems/sentence-screen-fitting

http://bookshadow.com/weblog/2016/10/09/leetcode-sentence-screen-fitting/

http://www.cnblogs.com/reboot329/p/5947854.html

第二篇提到另一种做法:

主要说一下DISCUSS里的另一种方法。
整个句子,理论上说每一个单词都有可能作为某一行的开头,我们要计算一下如果以某个单词开头,会是什么结果。结果包括两部分:
1)这一行能塞多少个句子。
2)下一行开头会以什么单词开头。
知道这2个情况之后,以此塞满所有ROWS就行了。

 

https://leetcode.com/problems/valid-word-square

http://blog.csdn.net/liuchenjane/article/details/52830773

较简单,上面的解法异常处理不全。主要看题目就好了。

 

 

以上是关于Todo所有Locked的题目的分析解答的主要内容,如果未能解决你的问题,请参考以下文章

Leetcode:Task Scheduler分析和实现

TODO:Github的使用技巧之同步代码

几道道简单的java题目 求解答,分析过程 在线等能够

Realm和RecyclerView项目排序和自动ViewPager片段通信

Backbone.js之Todo源码浅析

需要帮助了解此 TODO 提供程序