【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的题目的分析解答的更多相关文章
- JAVA经典算法40题及解答
JAVA经典算法40题 [程序1] 题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第四个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少? 1.程序分 ...
- JavaScript基础知识----六道有趣的Js基础题以及解答
题目: 1.找出数字数组中最大的元素(使用Math.max函数)2.转化一个数字数组为function数组(每个function都弹出相应的数字)3.给object数组进行排序(排序条件是每个元素对象 ...
- Cracking the coding interview--问题与解答
http://www.hawstein.com/posts/ctci-solutions-contents.html 作者:Hawstein出处:http://hawstein.com/posts/c ...
- 几个面试经典算法题Java解答
题目一: public class testClockwiseOutput { //顺时针打印一个矩阵 @Test public void test(){ int[][] num = new int[ ...
- leetcode题库解答源码(python3)
下面和大家分享本人在leetcode上已经ace的题目源码(python3): 本人会持续更新!- class Leetcode_Solution(object): def twoSum_1(self ...
- 笔试算法题及解答(Python)
1.给定任意一个正整数,求比这个数大且最小的“不重复数”,“不重复数”的含义是相邻两位不相同,例如1101是重复数,而1201是不重复数 # coding:utf-8 ''' Created on 2 ...
- Z字形扫描(201412-2)
问题描述 在图像编码的算法中,需要将一个给定的方形矩阵进行Z字形扫描(Zigzag Scan).给定一个n×n的矩阵,Z字形扫描的过程如下图所示: 对于下面的4×4的矩阵, 1 5 3 9 3 7 5 ...
- 大公司面试经典数据结构与算法题C#/Java解答
几个大公司(IBM.MicroSoft and so on)面试经典数据结构与算法题C#解答 1.链表反转 我想到了两种比较简单的方法 第一种是需要开一个新的链表,将原链表的元素从后到前的插入到新链表 ...
- AWS助理架构师样题解析
AWS 认证是对其在 AWS 平台上设计.部署和管理应用程序所需的技能和技术知识的一种认可.获得证书有助于证明您使用 AWS 的丰富经验和可信度,同时还能提升您所在的组织熟练使用基于 AWS 云服务应 ...
随机推荐
- STMPClient 发送邮件显示 不允许使用邮件名称.
在.net 2.0,3.5, 针对某些邮箱(还不清楚是什么样的邮件) , 使用微软自带的DLL发送邮件会提示不允许使用邮件名称 .... 使用Jmail可以发送. 解决方案: 1. ...
- 常量折叠 const folding
http://bbs.byr.cn/#!article/CPP/86336?p=1 下列代码给出输出结果: #include"stdafx.h" #include <iost ...
- MariaDB Galera Cluster集群
一.MariaDB Galera Cluster概要: 1.简述: MariaDB Galera Cluster 是一套在mysql innodb存储引擎上面实现multi-master及数据实时同步 ...
- 最长连续回文串(最优线性时间O(n))
转自:http://blog.csdn.net/hopeztm/article/details/7932245 Given a string S, find the longest palindrom ...
- SGU 104
104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB PROBLEM Yo ...
- 使用git了解代码编写过程
在看教程时,有的老师会将代码放到github,如果不想跟着视频一步一步来,那就直接clone整个代码,但整个看着又有点蒙,那就使用版本切换的功能了. 首先 git clone 下载下来 git log ...
- Webpack教程一
比较 如果你熟悉原来一系列的构建工具,grunt或者gulp之类的,这里有一篇webpack和他们比较的文章可以读一读. Webpack Compared 安装 先装好node和npm,因为webpa ...
- 离开csdn来到blog园
csdn里没有限制阅读访问的功能,所以我选择来到cnblog 但是不得不说,cnblog做的界面很丑,我个人很不喜欢,但是没办法
- node中的模块
模块 编写稍大一点的程序时一般都会将代码模块化.在NodeJS中,一般将代码合理拆分到不同的JS文件中,每一个文件就是一个模块,而文件路径就是模块名. 在编写每个模块时,都有require.expor ...
- Linux - wxWidgets安装和编译HelloWorld
安装参考http://codelite.org/LiteEditor/WxWidgets30Binaries#toc2 源 /etc/apt/source.list deb http://repos. ...