重新写了下,代码看着清爽多了 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x...
分类:
其他好文 时间:
2014-09-04 20:54:00
阅读次数:
162
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.
Return a deep copy of the list.
/**
* Definition for singly-lin...
分类:
其他好文 时间:
2014-09-04 19:12:40
阅读次数:
201
LeetCode: Remove Duplicates from Sorted ListGiven a sorted linked list, delete all duplicates such that each element appear only once. For example,Giv...
分类:
其他好文 时间:
2014-09-03 22:27:17
阅读次数:
311
Sort a linked list in O(n log n) time using constant space complexity. 1 package SortList; 2 3 import java.util.Iterator; 4 5 class ListNode { 6 7 ...
分类:
编程语言 时间:
2014-09-03 21:00:47
阅读次数:
291
1、问题
define a class for a linked list and write a method to delete the nth node.
2、算法
template
struct Node{
C content ;
Node* next ;
}
template
class List{
private:...
分类:
其他好文 时间:
2014-09-03 13:10:36
阅读次数:
189
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy ...
分类:
其他好文 时间:
2014-09-02 10:19:24
阅读次数:
194
LeetCode: Partition ListGiven 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.Y...
分类:
其他好文 时间:
2014-09-02 00:05:33
阅读次数:
235
Remove Duplicates from Sorted List
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, r...
分类:
其他好文 时间:
2014-09-01 17:42:53
阅读次数:
195
题目:Insertion Sort ListSort a linked list using insertion sort.题目比较简单,就是对链表进行插入排序个人思路:1,用插入排序的方法来解就行,注意链表的处理,可以给原链表加个头结点来使得处理统一(我的代码没有加,懒得改了)代码: 1 #inc...
分类:
其他好文 时间:
2014-09-01 12:21:53
阅读次数:
206
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-...
分类:
其他好文 时间:
2014-09-01 12:15:43
阅读次数:
169