随笔分类 -  leetcode

摘要:https://leetcode.com/problems/linked-list-cycle-ii/#/description 阅读全文
posted @ 2017-07-05 20:09 apanda009 阅读(141) 评论(0) 推荐(0)
摘要:Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here ak-diff pair is defined as an integ 阅读全文
posted @ 2017-07-05 15:23 apanda009 阅读(157) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/longest-word-in-dictionary-through-deleting/#/solutions Given a string and a string dictionary, find the longest string 阅读全文
posted @ 2017-07-05 14:38 apanda009 阅读(174) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/reverse-vowels-of-a-string/#/description http://www.cnblogs.com/EdwardLiu/p/6096319.html 阅读全文
posted @ 2017-07-05 13:44 apanda009 阅读(137) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/partition-list/#/description http://www.cnblogs.com/EdwardLiu/p/3807137.html Given a linked list and a value x, partitio 阅读全文
posted @ 2017-07-03 17:38 apanda009 阅读(133) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/remove-element/#/description Given an array and a value, remove all instances of that value in place and return the new 阅读全文
posted @ 2017-07-01 19:03 apanda009 阅读(131) 评论(0) 推荐(0)
摘要:https://leetcode.com/problemset/all/?search=19 涉及链表删除操作的时候,稳妥起见都用 dummynode,省去很多麻烦。因为不一定什么时候 head 就被删了。 快慢指针 阅读全文
posted @ 2017-07-01 18:36 apanda009 阅读(136) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/4sum/#/solutions Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target 阅读全文
posted @ 2017-07-01 18:05 apanda009 阅读(132) 评论(0) 推荐(0)
摘要:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. 阅读全文
posted @ 2017-07-01 16:49 apanda009 阅读(147) 评论(0) 推荐(0)
摘要:为何不像76. Minimum Window Substring用数组来匹配, 是因为双指针是根据字符串的顺序遍历的, 而数组的话没有顺序.如 For example,S = "ADOBECODEBANC"T = "ABC" Minimum window is "BANC". 并不是非得ABC的顺序 阅读全文
posted @ 2017-07-01 11:24 apanda009 阅读(385) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/count-complete-tree-nodes/#/description http://www.cnblogs.com/EdwardLiu/p/5058570.html 递归树高法 复杂度 时间 O(N) 空间 O(1) 思路 完全二 阅读全文
posted @ 2017-06-30 11:25 apanda009 阅读(151) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/minimum-size-subarray-sum/#/solutions Since the given array contains only positive integers, the subarray sum can only i 阅读全文
posted @ 2017-06-29 18:06 apanda009 阅读(196) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/valid-perfect-square/#/solutions 数学问题常考虑是否越界, 用long? 阅读全文
posted @ 2017-06-29 10:25 apanda009 阅读(140) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/search-a-2d-matrix/#/solutions 考点只有一个:2D array 降维成 1D array 的 index trick. 阅读全文
posted @ 2017-06-29 10:10 apanda009 阅读(166) 评论(0) 推荐(0)
摘要:https://leetcode.com/submissions/detail/107115768/ http://www.cnblogs.com/EdwardLiu/p/3978972.html 画图分情况讨论: 根据1 增添之 The idea is that when rotating the 阅读全文
posted @ 2017-06-24 11:17 apanda009 阅读(163) 评论(0) 推荐(0)
摘要:https://leetcode.com/submissions/detail/106698735/ 要求O(logN)的时间复杂度,想到用二分查找。如果中间元素大于其相邻后续元素,则中间元素左侧(包含该中间元素)必包含一个局部最大值。如果中间元素小于其相邻后续元素,则中间元素右侧必包含一个局部最大 阅读全文
posted @ 2017-06-20 22:15 apanda009 阅读(130) 评论(0) 推荐(0)
摘要:http://www.cnblogs.com/EdwardLiu/p/6197086.html https://leetcode.com/problems/heaters/#/description Binary Search My solution: Be careful in my binary 阅读全文
posted @ 2017-06-20 21:09 apanda009 阅读(179) 评论(0) 推荐(0)