题目:Remove Duplicates from Sorted ListGiven a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2...
分类:
其他好文 时间:
2014-07-10 14:29:45
阅读次数:
259
题目:Given a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1->2->3->4->5, and n = 2.After rem...
分类:
其他好文 时间:
2014-07-07 19:01:42
阅读次数:
155
Problem Description:Given a binary tree, flatten it to a linked list in-place.Solution:对二叉树进行前序遍历(pre-order). 1 public void flatten(TreeNode root) { 2...
分类:
其他好文 时间:
2014-07-07 18:47:24
阅读次数:
306
【问题】
Sort a linked list in O(n log n)
time using constant space complexity.
【代码】
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# ...
分类:
编程语言 时间:
2014-06-28 08:29:23
阅读次数:
222
【问题】
Sort a linked list using insertion sort.
【代码】
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Sol...
分类:
编程语言 时间:
2014-06-28 07:55:49
阅读次数:
199
#includeusing namespace std;class Node{public: Node(int value) : value(value), next(NULL) {}public: int value; Node* next;};Node* reverseList...
分类:
编程语言 时间:
2014-06-27 20:02:00
阅读次数:
253
题目:Linked List CycleGiven a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?个人思路:1、判断一个链表是否有环,标准做法...
分类:
其他好文 时间:
2014-06-27 19:41:40
阅读次数:
165
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
分类:
其他好文 时间:
2014-06-27 12:48:46
阅读次数:
259
Given a linked list, swap every two adjacent nodes and return its head.
分类:
其他好文 时间:
2014-06-27 12:42:55
阅读次数:
198
Given a linked list, remove the nth node from the end of list and return its head.
分类:
其他好文 时间:
2014-06-27 12:26:10
阅读次数:
322