题目描述:Sort a linked list using insertion sort.解决方案:该题目就是用插入排序来对链表进行排序,很简单,直接上代码。 1 class Solution { 2 public: 3 ListNode *insertionSortList(ListNod...
                            
                            
                                分类:
其他好文   时间:
2014-09-24 19:49:57   
                                阅读次数:
137
                             
                    
                        
                            
                            
                                有关python单链表的实现代码。链表的定义:链表(linked list)是由一组被称为结点的数据元素组成的数据结构,每个结点都包含结点本身的信息和指向下一个结点的地址。由于每个结点都包含了可以链接起来的地址信息,所以用一个变量就能够访问整个结点序列。也就是说,结点包含两部分信息:一部分用于存储数...
                            
                            
                                分类:
编程语言   时间:
2014-09-24 08:02:36   
                                阅读次数:
248
                             
                    
                        
                            
                            
                                题目:Sort a linked list using insertion sort.代码: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNod...
                            
                            
                                分类:
其他好文   时间:
2014-09-24 01:57:35   
                                阅读次数:
227
                             
                    
                        
                            
                            
                                题目:
Given a linked list, determine if it has a cycle in it.
Follow up:
Can you solve it without using extra space?
这是一道关于链表比较简单的题,很顺利就解决了,不多说啦,上代码啦
# Definition for singly-linked list.
# ...
                            
                            
                                分类:
其他好文   时间:
2014-09-22 22:07:03   
                                阅读次数:
233
                             
                    
                        
                            
                            
                                Sort a linked list using insertion sort.思路:插入排序#include using namespace std;struct ListNode { int val; ListNode *next; ListNode(int x): val(x...
                            
                            
                                分类:
其他好文   时间:
2014-09-22 03:01:31   
                                阅读次数:
159
                             
                    
                        
                            
                            
                                Given a linked list, return the node where the cycle begins. If there is no cycle, return null.
Follow up:
Can you solve it without using extra space?
/**
 * Definition for singly-linked list.
...
                            
                            
                                分类:
其他好文   时间:
2014-09-21 18:31:21   
                                阅读次数:
233
                             
                    
                        
                            
                            
                                Sort a linked list inO(nlogn) time using constant space complexity.思路:采用归并排序或者快速排序#include using namespace std;struct ListNode { int val; ListNo...
                            
                            
                                分类:
其他好文   时间:
2014-09-20 20:12:09   
                                阅读次数:
230
                             
                    
                        
                            
                            
                                /**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
struct ListNode
{
	int val;
	ListNode *ne...
                            
                            
                                分类:
其他好文   时间:
2014-09-20 15:36:29   
                                阅读次数:
152
                             
                    
                        
                            
                            
                                Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
You must do this in-place without altering the nodes' values.
For example,
Given {1,2,3,4}, reorder it to ...
                            
                            
                                分类:
其他好文   时间:
2014-09-20 10:07:27   
                                阅读次数:
162
                             
                    
                        
                            
                            
                                Remove Nth Node From End of ListGiven a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1-.....
                            
                            
                                分类:
其他好文   时间:
2014-09-19 22:26:26   
                                阅读次数:
216