码迷,mamicode.com
首页 >  
搜索关键字:两指针    ( 54个结果
LeetCode的medium题集合(C++实现)十四
1 Sort Colors Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use th...
分类:编程语言   时间:2015-05-26 10:46:21    阅读次数:177
LeetCode的medium题集合(C++实现)九
1 Jump Game Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determ...
分类:编程语言   时间:2015-05-21 12:48:33    阅读次数:144
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 ...
分类:其他好文   时间:2015-05-08 10:59:19    阅读次数:181
kSum问题的总结
kSum问题是一类题型,常见的有2Sum,3Sum,4Sum等。这篇博文就来总结一些kSum问题的解法,以及对应的时间复杂度。     1. 2Sum     在一个给定的数组nums中,寻找和为定值target的两个数。     【解法1】:把数组排序,然后使用two pointers的方法来求解。时间复杂度分析:排序O(nlogn),两指针遍历O(n),总体O(nlogn). ...
分类:其他好文   时间:2015-05-07 14:44:35    阅读次数:1856
121:Best Time to Buy and Sell Stock【数组】【两指针】
题目链接:click~/*题意:一个数组,第i元素表示第i天股票的价格,只允许买卖一次,求最大利润 *//** *思路:两个指针,一个扫描整个数组,另一个记录已扫描元素的最小值 * 扫描过程中,一边更新最小值,一边更新最大利润 * 最大利润:max(A[j]-A[i]),j>i ...
分类:编程语言   时间:2015-04-10 15:27:17    阅读次数:144
19:Remove Nth Node From End of List【两指针】【链表】
题目连接:https://leetcode.com/problems/remove-nth-node-from-end-of-list//** * Definition for singly-linked list. * struct ListNode { * int val; * ...
分类:其他好文   时间:2015-04-07 19:34:12    阅读次数:95
61:Rotate List(旋转链表)【链表】【两指针】
题目链接:https://leetcode.com/problems/rotate-list//* 题意:给出一个链表,将链表向右旋转k个位置 *//** *思路:右旋k个位置,相当与将链表从第len-k个位置截断,然后 * 将两截链表交换位置,重新链接成一个链表 * */stru...
分类:其他好文   时间:2015-04-03 14:47:32    阅读次数:113
Linked List Cycle II
给出一个链表,假如这个链表有环,返回这个环的起点,否则返回null做法:用两个指针,p1 表示慢指针,p2表示快指针,快指针每次走2步,慢指针每次走一步,如果没环,必然是以p2->next->next = null或者p1 = null结束,如果有环p1与p2必然会相遇,当两指针相遇时使p1 指向h...
分类:其他好文   时间:2015-03-19 23:23:55    阅读次数:97
lightoj 1293 - Document Analyzer [ 两指针 + 字符串 ]
传送门1293 - Document Analyzer PDF (English) Statistics Forum Time Limit: 3 second(s)Memory Limit: 32 MBYou work in a leading software development comp.....
分类:其他好文   时间:2015-03-14 10:59:04    阅读次数:143
poj 3267 The Cow Lexicon 动态规划
字符串动态规划 匹配时两指针的重要思想 针对原串从后往前 不需要string类
分类:其他好文   时间:2015-02-15 19:23:05    阅读次数:154
54条   上一页 1 ... 3 4 5 6 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!