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
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
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 第4题 替换空格
* 特点:1、先扫描串中的空格数,计算好替换后的长度
* 2、使用双指针,从后面开始向前替换,避免从前开始每次替换后就要移动后面的所有的数据
* 测试用例:特殊:有多个空格
* 错误:数组长度不够,字符串为空
*
*/
package javaTrain;
public class Offer4 {
public sta...
分类:
其他好文 时间:
2015-04-12 21:11:33
阅读次数:
128
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
题目:
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
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
看了别人讨论,双指针比较方便http://www.cnblogs.com/springfor/p/3862042.htmlpublic class Solution { public ListNode deleteDuplicates(ListNode head) { if(he...
分类:
其他好文 时间:
2015-04-08 06:43:39
阅读次数:
147
题目链接: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
题目链接: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