【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 云服务应 ...
随机推荐
- javascript实现数据结构:串--定长顺序存储表示以及kmp算法实现
串(string)(或字符串)是由零个或多个字符组成的有限序列.串中字符的数目称为串的长度.零个字符的串称为空串(null string),它的长度为零. 串中任意个连续的字符组成的子序列称为该串的子 ...
- linux 上传/下载文件到windows工具
一般来说,linux服务器大多是通过ssh客户端来进行远程的登陆和管理的,使用ssh登陆linux主机以后,如何能够快速的和本地机器进行文件的交互呢,也就是上传和下载文件到服务器和本地: 与ssh ...
- ExtJs布局之tabPanel
<!DOCTYPE html> <html> <head> <title>ExtJs</title> <meta http-equiv ...
- jmeter 302请求测试
需求,测试url: http://test.123.com/123.action,请求该url之后会进行302跳转,判断跳转的页面是不是http://www.haha.com. 这个其实本质还是普通 ...
- 点击UITableView的cell展开收缩
在项目中有个需求,点击表视图的单元格展开,再点击另外一个单元格或者本身又收缩,经过一段时间尝试,实现了该功能,现在记录分享总结下. 首先要理解UITableView代理方法调用的先后顺序. 当 ...
- JavaWeb项目开发案例精粹-第4章博客网站系统-002辅助类及配置文件
1. <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5&qu ...
- 谈谈MVC模式
谈谈MVC模式 作者: 阮一峰 1. 如何设计一个程序的结构,这是一门专门的学问,叫做"架构模式"(architectural pattern),属于编程的方法论. MVC模式 ...
- C++虚函数的缺陷
MFC中的消息机制没有采用C++中的虚函数机制,原因是消息太多,虚函数内存开销太大.在Qt中也没有采用C++中的虚函数机制,原因与此相同,其实这里还有更深层次上的原因,大体说来,多态的底层实现机制只有 ...
- OneThink实现多图片批量上传功能
OneThink原生系统中的图片上传功能是uploadify.swf插件进行上传的,默认是只能上传一张图片的,但是uploadify.swf是支持多图片批量上传的,那么我们稍加改动就可实现OneThi ...
- android学习笔记二:Intent
1.Intent作用 协助完成各个组建间的通信.如activity间.启动service.Broadcast. 2.Intent构成 1.Componet name:要启动的目的组建. 2.Actio ...