码迷,mamicode.com
首页 >  
搜索关键字:双指针    ( 649个结果
leetcode || 86、Partition List
problem: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of...
分类:其他好文   时间:2015-04-14 19:45:50    阅读次数:149
leetcode || 83、Remove Duplicates from Sorted List
problem: Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. Hid...
分类:其他好文   时间:2015-04-13 19:03:50    阅读次数:143
leetcode || 82、Remove Duplicates from Sorted List II
problem: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, Given 1->2->3->3->4->4->5, return 1...
分类:其他好文   时间:2015-04-13 19:03:43    阅读次数:121
【剑指offer】第四题 替换空格
/** * 剑指offer 第4题 替换空格 * 特点:1、先扫描串中的空格数,计算好替换后的长度 * 2、使用双指针,从后面开始向前替换,避免从前开始每次替换后就要移动后面的所有的数据 * 测试用例:特殊:有多个空格 * 错误:数组长度不够,字符串为空 * */ package javaTrain; public class Offer4 { public sta...
分类:其他好文   时间:2015-04-12 21:11:33    阅读次数:128
leetcode || 80、Remove Duplicates from Sorted Array II
problem: Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? For example, Given sorted array A = [1,1,1,2,2,3], Your function should return length = 5, ...
分类:其他好文   时间:2015-04-10 18:02:27    阅读次数:99
Leetcode: 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 the integers...
分类:其他好文   时间:2015-04-10 11:27:26    阅读次数:129
leetcode || 75、Sort Colors
problem: 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 wi...
分类:其他好文   时间:2015-04-09 17:32:33    阅读次数:105
Remove Duplicates from Sorted List
看了别人讨论,双指针比较方便http://www.cnblogs.com/springfor/p/3862042.htmlpublic class Solution { public ListNode deleteDuplicates(ListNode head) { if(he...
分类:其他好文   时间:2015-04-08 06:43:39    阅读次数:147
LeetCode --- 88. Merge Sorted Array
题目链接:Merge Sorted Array Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You may assume that A has enough space (size that is greater or equal to m + n) to hold ad...
分类:其他好文   时间:2015-04-07 23:34:47    阅读次数:349
LeetCode --- 86. Partition List
题目链接:Partition List Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of t...
分类:其他好文   时间:2015-04-07 23:33:18    阅读次数:292
649条   上一页 1 ... 58 59 60 61 62 ... 65 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!