码迷,mamicode.com
首页 >  
搜索关键字:双指针    ( 649个结果
LeetCode --- 42. Trapping Rain Water
题目链接: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 ...
分类:移动开发   时间:2015-02-09 00:48:49    阅读次数:207
LeetCode --- 30. Substring with Concatenation of All Words
题目链接:Substring with Concatenation of All Words You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatena...
分类:其他好文   时间:2015-02-02 23:09:55    阅读次数:253
【BZOJ1071】【SCOI2007】组队 利用单调性的双指针
题解:O(n*n) 首先我们先外圈枚举一个最小权值一 然后内圈再枚举一个最小权值二 然后每次外圈枚举完了就重置一下双指针, 每次内圈枚举的时候右指针右移把总条件符合的加进去,其中第二个权值符合枚举条件的计数。 然后左指针右移把第一个权值不符合的清出去,其中第而个权值符合枚举条件的计数。 因为单调性问题,所以不会有l>r 的情况(第一权值不符合的在右指针右移时,第...
分类:其他好文   时间:2015-02-02 14:15:27    阅读次数:159
LeetCode --- 27. Remove Element
题目链接:Remove Element Given an array and a value, remove all instances of that value in place and return the new length. The order of elements can be changed. It doesn't matter what you leave beyond t...
分类:其他好文   时间:2015-02-02 12:34:19    阅读次数:158
LeetCode --- 26. Remove Duplicates from Sorted Array
题目链接:Remove Duplicates from Sorted Array Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for ano...
分类:其他好文   时间:2015-02-02 12:34:17    阅读次数:151
LeetCode --- 28. Implement strStr()
题目链接:Implement strStr() Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Update (2014-11-02): The signature of the func...
分类:其他好文   时间:2015-02-02 12:31:43    阅读次数:135
Leetcode#27 Remove Element
原题地址基本模拟题,双指针法代码: 1 int removeElement(int A[], int n, int elem) { 2 int i = 0; 3 int j = 0; 4 5 while (i < n) { 6 ...
分类:其他好文   时间:2015-02-02 12:00:21    阅读次数:128
LeetCode --- 19. Remove Nth Node From End of List
题目链接: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 ...
分类:其他好文   时间:2015-01-30 22:43:16    阅读次数:179
LeetCode --- 18. 4Sum
题目链接: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: ...
分类:其他好文   时间:2015-01-30 22:42:54    阅读次数:251
LeetCode --- 16. 3Sum Closest
题目链接: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...
分类:其他好文   时间:2015-01-30 22:42:30    阅读次数:252
649条   上一页 1 ... 60 61 62 63 64 65 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!