随笔分类 - leetcode
摘要:http://www.cnblogs.com/charlesblc/p/6384132.html 继续过Hard模式的题目吧。 题目挺好的,但是描述太复杂。思路还是蛮清晰的。
阅读全文
摘要:http://www.cnblogs.com/charlesblc/p/6384132.html 继续过Hard模式的题目吧。 这道题目很好,是使用DP的典型方案。可惜我开始还是没能做出来。Discuss的解法非常好。好好学习。 bool isInterleave(string s1, string
阅读全文
摘要:http://www.cnblogs.com/charlesblc/p/6372971.html 继续过Hard模式的题目吧。 挺难的,可以看这里: https://discuss.leetcode.com/topic/38014/java-oms-with-explanation
阅读全文
摘要:接上一篇:http://www.cnblogs.com/charlesblc/p/6364102.html 继续过Hard模式的题目吧。 题目还是很难的,基本看懂了。里面的greater和merge函数都用的不错: https://discuss.leetcode.com/topic/32272/s
阅读全文
摘要:https://leetcode.com/problems/regular-expression-matching/ 我觉得这个递归解法很好,简洁明了: 也可以方便的改成DP.
阅读全文
摘要:https://leetcode.com/problems/find-median-from-data-stream/ 这道题目实在是不错,所以单独拎出来。 https://discuss.leetcode.com/topic/27521/short-simple-java-c-python-o-l
阅读全文
摘要:接上一篇:http://www.cnblogs.com/charlesblc/p/6283064.html 继续过Hard模式的题目吧。 Valid Number Word Ladder II Max Points on a Line LRU Cache Text Justification LFU
阅读全文
摘要:先过一下Hard模式的题目吧。 Valid Number Word Ladder II Max Points on a Line LRU Cache Text Justification LFU Cache Wildcard Matching Range Sum Query 2D - Mutable
阅读全文
摘要:今天看到这道题目:http://www.cnblogs.com/charlesblc/p/5930311.html 题目地址:https://leetcode.com/problems/split-array-largest-sum/ 很好,也很难。开拓了思路,用二分法来查找结果备选,然后直接划分原
阅读全文
摘要:唉,要开始好好准备面试了。 今天看到一道题目: 一个字符串,删除其中部分字母,能够组成的最长的回文串,是多长? 这道经典的题目,我居然开始的时候没想出来!虽然想到了动态规划,但是居然想到了首尾不同的话,尾部还要遍历,平白增加了非常多的编程复杂度。。。。。而实际上,只要简单的首尾比较然后动态规划就可以
阅读全文
摘要:https://leetcode.com/problems/heaters/ 开始的时候,下面的代码对于两边数字完全一样的情况,测试不通过。原因是heater会有重复情况,这时候对于飘红部分就不会往前面继续检查。所以把<改成<=让相同的情况也继续往前面走,走到最后一个,就可以了。Accepted!
阅读全文
摘要:https://leetcode.com/problems/unique-substrings-in-wraparound-string/ 好,我自己做出来的。多总结规律,多思考。
阅读全文
摘要:https://leetcode.com/problems/count-the-repetitions/ 下面是我的方法,结果对的,超时了。。。 优化之后的结果,还是超时: 加了string到array的优化,另外每次循环之后坐个判断剪枝。 用了这种Brute Force的方法,居然比我的快。。。。
阅读全文
摘要:https://leetcode.com/problems/number-of-segments-in-a-string/
阅读全文
摘要:今天看到了这篇文章,非常非常棒:http://blog.csdn.net/nedushy123/article/details/23827361 把内容转载如下,以作收藏: 经典算法面试题一览 1. 自然就是careercup (类似的网站还有glassdoor) careercup不难,参考二爷划
阅读全文
摘要:https://leetcode.com/problems/lfu-cache/ 很难,看了下面的参考: https://discuss.leetcode.com/topic/69137/java-o-1-accept-solution-using-hashmap-doublelinkedlist-
阅读全文
摘要:https://leetcode.com/problems/can-i-win/
阅读全文
摘要:https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/
阅读全文
摘要:https://leetcode.com/problems/island-perimeter/
阅读全文
摘要:https://leetcode.com/problems/repeated-substring-pattern/ 下面这个方法,开始我觉得挺好。可惜还是超时了。后来我就加了一个剪枝策略,只有长度能够整除总长度的子串,才需要进行比较。 下面是开始超时的方法,少了一个剪枝条件。
阅读全文

浙公网安备 33010602011771号