随笔分类 - leetcode
摘要:https://leetcode.com/problems/132-pattern/ 下面是我的做法。后来又看了一个提示: https://discuss.leetcode.com/topic/67881/single-pass-c-o-n-space-and-time-solution-8-lin
阅读全文
摘要:https://leetcode.com/problems/assign-cookies/ 用贪心算法即可。
阅读全文
摘要:https://leetcode.com/problems/4sum-ii/ 用了个两两匹配的方法,还是不错的
阅读全文
摘要:https://leetcode.com/problems/implement-stack-using-queues/ 还有种方法,就是利用同一个队列,知道队列长度前提下,把内容从头到尾,再向尾部依次重推一下。
阅读全文
摘要:https://leetcode.com/problems/circular-array-loop/ 题目蛮难的,有一些坑。 前后两个指针追赶找环的方法,基本可以归结为一种定式。可以多总结。
阅读全文
摘要:https://leetcode.com/problems/poor-pigs/
阅读全文
摘要:https://leetcode.com/problems/minimum-moves-to-equal-array-elements/
阅读全文
摘要:https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/ 与会议室排期问题,很相似。
阅读全文
摘要:https://leetcode.com/problems/number-of-boomerangs/
阅读全文
摘要:https://leetcode.com/problems/arithmetic-slices-ii-subsequence/ 太难了。。。
阅读全文
摘要:https://leetcode.com/problems/h-index/ https://leetcode.com/mockinterview/session/result/xjcpjlh/ 看了hint,不然的话,可能用的是排序的方法,O(NlgN),现在的方法用了extra space,但是
阅读全文
摘要:https://leetcode.com/problems/create-maximum-number/ 这道题目太难了,花了我很多时间。最后还是参考了别人的方法。还少加了个greater方法。很难。
阅读全文
摘要:https://leetcode.com/problems/reverse-nodes-in-k-group/ https://leetcode.com/mockinterview/session/result/xjlzcwc/ 链表分批倒置,还是有点绕的。用了三个临时变量来处理。需要细心,也需要掌
阅读全文
摘要:https://leetcode.com/problems/simplify-path/ https://leetcode.com/mockinterview/session/result/xjl3d3m/ 现在字符串比较,都知道用 equals了,哈哈。不能用==,否则可能有bug。
阅读全文
摘要:https://leetcode.com/problems/search-insert-position/ https://leetcode.com/mockinterview/session/result/xjw45dt/ 这是一个典型的二分查找。注意一些坑。比如里面start end的设置,到了
阅读全文
摘要:https://leetcode.com/problems/sort-characters-by-frequency/ 用了Jave Map.Entry这个数据结构,还用到了自定义的Comparator。
阅读全文
摘要:https://leetcode.com/problems/delete-node-in-a-bst/
阅读全文
摘要:https://leetcode.com/problems/serialize-and-deserialize-bst/ 1. 用到Java Queue接口, // LinkedList实现了Queue接口, ArrayList没有实现 2. 用的Java String.split 函数得到 Str
阅读全文
摘要:https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/ 之前有一道题目:http://www.cnblogs.com/charlesblc/p/5998825.html "find-all-duplicates-
阅读全文
摘要:https://leetcode.com/problems/find-right-interval/ Java里面TreeMap或者TreeSet有类似C++的lower_bound或者upper_bound的函数:floor(取出不大于xx的)和ceiling(取出不小于xx的)
阅读全文

浙公网安备 33010602011771号