Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space?怎样判断一个链表之中是否有环?可以利用快慢指针的方法。定义两个指针fast和slo...
分类:
其他好文 时间:
2014-11-10 23:15:29
阅读次数:
289
Remove Nth Node From End of ListGiven a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2.....
分类:
其他好文 时间:
2014-11-10 21:35:12
阅读次数:
173
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first
two lists.
递归版
/**
* Definition for singly-linked list.
...
分类:
其他好文 时间:
2014-11-10 13:55:03
阅读次数:
195
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.
/**
* Definition for sin...
分类:
其他好文 时间:
2014-11-10 10:07:22
阅读次数:
156
Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, retu...
分类:
其他好文 时间:
2014-11-09 20:51:20
阅读次数:
222
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
分类:
其他好文 时间:
2014-11-09 15:04:28
阅读次数:
180
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.Solution: 1 /** 2 * Definition for singl....
分类:
其他好文 时间:
2014-11-09 00:52:30
阅读次数:
316
Remove Duplicates from Sorted ListGiven a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, r...
分类:
其他好文 时间:
2014-11-09 00:49:14
阅读次数:
173
[Description]find the k-th node from the last node of single linked list.e.g. Linked-list: 1-2-3-4-5-6-7-8-9 the last 4th node is: 6[Thought] usin...
分类:
其他好文 时间:
2014-11-08 18:16:32
阅读次数:
258
Sort a linked list using insertion sort.首先总结一下插入排序和冒泡排序吧!插入排序:1 void inssort(int a[],int n){2 int i,j;3 for(i=1;i0&&(a[j]0很容易出错,如果j=0的话,a[-1]没...
分类:
其他好文 时间:
2014-11-08 16:25:11
阅读次数:
150