
双指针
yuccess
这个作者很懒,什么都没留下…
展开
-
76. Minimum Window Substring, leetcode
题目:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum windo原创 2016-12-04 17:32:23 · 290 阅读 · 0 评论 -
109. Convert Sorted List to Binary Search Tree
题目:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.解法:/** * Definition for singly-linked list. * struct ListNode { * int val原创 2016-12-13 00:58:01 · 328 阅读 · 0 评论 -
18. 4Sum
题目:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: The原创 2016-11-25 23:45:39 · 260 阅读 · 0 评论 -
11. Container With Most Water 双指针问题
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Fin原创 2017-01-04 10:06:34 · 292 阅读 · 0 评论 -
15. 3Sum hash解法 vs 双指针解法
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain d原创 2017-01-05 00:45:30 · 1193 阅读 · 0 评论 -
16. 3Sum Closest 又是一道先排序再双指针问题
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. You may assume that each input would have exact原创 2017-01-05 01:21:24 · 309 阅读 · 0 评论 -
19. Remove Nth Node From End of List 一道简单的双指针
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the原创 2017-01-05 03:51:18 · 295 阅读 · 0 评论 -
42. Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1],原创 2017-01-06 21:52:03 · 272 阅读 · 0 评论