leetcode:Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…...
分类:
其他好文 时间:
2014-09-30 15:13:19
阅读次数:
123
Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor...
分类:
其他好文 时间:
2014-09-29 23:36:31
阅读次数:
258
Sort a linked list inO(nlogn) time using constant space complexity.1、分析该题主要考查了链接上的合并排序算法。2、正确代码实现package com.edu.leetcode;import com.edu.leetcode.List...
分类:
编程语言 时间:
2014-09-29 03:09:07
阅读次数:
315
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.
Your algorithm should use only constant space. Y...
分类:
其他好文 时间:
2014-09-29 01:40:57
阅读次数:
297
【题目】Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?【题意】 推断一个单向链表是否有环【思路】 维护两个指针p1和p2,p1.....
分类:
其他好文 时间:
2014-09-28 21:16:55
阅读次数:
195
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.
Your algorithm should use only constant space. Y...
分类:
其他好文 时间:
2014-09-28 14:33:56
阅读次数:
178
题目描述:Sort a linked list inO(nlogn) time using constant space complexity.解题方案:题目要求的时间复杂度是O(nlogn),常数级空间复杂度。所以这里用了归并排序,归并排序在数组上操作比较方便,但是这里要排序的是链表。我们用到两个...
分类:
其他好文 时间:
2014-09-27 18:56:10
阅读次数:
231
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-l...
分类:
其他好文 时间:
2014-09-26 15:07:08
阅读次数:
181
题目:
Given a sorted linked list, delete all duplicates such that each element appear only once.
这道链表的题也比较简单,目标是为了去重,只是需要注意在去重的过程中需要使用while循环,使一个节点的下一个节点必须指向与其不同的节点
上代码咯
# Definition for singly-li...
分类:
其他好文 时间:
2014-09-25 18:39:57
阅读次数:
193
LeetCode算法题Linked List Cycle 和Linked List Cycle II 详解...
分类:
其他好文 时间:
2014-09-25 16:32:09
阅读次数:
162