[leetcode]Given 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....
分类:
其他好文 时间:
2014-10-14 11:44:49
阅读次数:
140
Insertion Sort List
Total Accepted: 24444 Total
Submissions: 96639My Submissions
Sort a linked list using insertion sort.
题意:用插入排序对一个链表排序
思路:
插入排序对当前元素在前面已经排好的元素中找到一个位置...
分类:
其他好文 时间:
2014-10-13 14:11:30
阅读次数:
135
1 /** 2 * Definition for singly-linked list. 3 * public class ListNode { 4 * int val; 5 * ListNode next; 6 * ListNode(int x) { 7 * ...
分类:
其他好文 时间:
2014-10-13 13:30:09
阅读次数:
118
算法导论:10.2-7 给出一个 O(n) 时间的非递归过程,实现对一个含有 n 个元素的单链表的逆转。要求除存储链表本身所需的空间外,该过程只能使用固定大小的存储空间。
#ifndef _SINGLY_LINKED_LIST_H
#define _SINGLY_LINKED_LIST_H
/***************************************************...
分类:
其他好文 时间:
2014-10-13 09:31:11
阅读次数:
185
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.
For example,
Given 1->2->3->3->4->4->5, return 1->2->5.
Given 1->1-...
分类:
其他好文 时间:
2014-10-12 15:51:58
阅读次数:
190
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 s...
分类:
其他好文 时间:
2014-10-12 13:59:18
阅读次数:
182
It is quite a basic problem. However I spent half an hour solving it and made two mistakes. Guess it's because I haven't written some fundamental data structures like linked list for a while and kind...
分类:
其他好文 时间:
2014-10-12 09:08:27
阅读次数:
176
This is a very good linked list question, as there are tricky cases you have to consider, and getting them all right in one place is harder than it lo...
分类:
其他好文 时间:
2014-10-12 05:54:07
阅读次数:
161
Partition List
Total Accepted: 19761 Total
Submissions: 73252My Submissions
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than ...
分类:
其他好文 时间:
2014-10-12 01:31:37
阅读次数:
317
Convert Sorted List to Binary Search Tree
Total Accepted: 21420 Total
Submissions: 78476My Submissions
Given a singly linked list where elements are sorted in ascending order, convert it ...
分类:
其他好文 时间:
2014-10-12 00:00:36
阅读次数:
250