码迷,mamicode.com
首页 >  
搜索关键字:有序链表    ( 417个结果
leetcode Convert Sorted List to Binary Search Tree
把一个有序链表构成成平衡二叉树。和上一题有一点像。思路一:将有序链表存在一个数组里。然后根据每次访问中间节点当做根节点递归左右子树节点即可。代码如下:/** * Definition for singly-linked list. * struct ListNode { * int val;...
分类:其他好文   时间:2014-11-29 22:53:04    阅读次数:271
有序链表的合并
有序链表的合并是单链表的基本操作之一,本文分别用递归和非递归两种方式实现两个有序链表(不含头结点)的合并。...
分类:其他好文   时间:2014-11-22 18:54:36    阅读次数:243
LeetCode:Insertion Sort List
题目描述: Sort a linked list using insertion sort. 思路:在head之前插入一个假头结点,便于在head节点之前插值。遍历链表,对于每一个节点,在它前面的有序的节点中找到第一个比它大的节点,将它插到该节点的前面。链表遍历结束后即得到有序链表。 代码: ListNode * Solution::insertionSortList(...
分类:其他好文   时间:2014-11-21 10:38:31    阅读次数:148
LeetCode Remove Duplicates from Sorted List 删除有序链表中的重复结点
1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), ne...
分类:其他好文   时间:2014-11-19 13:51:14    阅读次数:222
leetcode[82] Remove Duplicates from Sorted List II
给定一个有序链表,删除相同值的节点。例如Given1->2->3->3->4->4->5, return1->2->5.Given1->1->1->2->3, return2->3.我是新建一个ans链表,来存链表中distinct的值。不知道这样符合要求不。判断当前的值不等于前面一个也不等于后面一...
分类:其他好文   时间:2014-11-18 01:38:12    阅读次数:134
数据结构之 线性表---有序链表的归并
数据结构实验之链表四:有序链表的归并Time Limit: 1000MS Memory limit: 65536K题目描述分别输入两个有序的整数序列(分别包含M和N个数据),建立两个有序的单链表,将这两个有序单链表合并成为一个大的有序单链表,并依次输出合并后的单链表数据。输入第一行输入M与N的值; ...
分类:其他好文   时间:2014-11-13 08:18:14    阅读次数:242
数据结构之 线性表---有序链表的建立
mxjj130304杨少鹏(13110581086) 注销数据结构实验之链表六:有序链表的建立数据结构实验之链表六:有序链表的建立Time Limit: 1000MS Memory limit: 65536K题目描述输入N个无序的整数,建立一个有序链表,链表中的结点按照数值非降序排列,输出该有序链....
分类:其他好文   时间:2014-11-12 00:27:48    阅读次数:220
链表操作二——合并,逆转
链表的基本操作合并,逆转:一:两个有序链表的合并(顺序从小到大依次排列) 1 #include 2 #include 3 #include 4 #include 5 6 typedef struct tag 7 { 8 int Nnum_; 9 struc...
分类:其他好文   时间:2014-11-10 23:12:11    阅读次数:330
Merge Two Sorted Lists 混合插入有序链表
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.这道混合插入有序链...
分类:其他好文   时间:2014-11-10 06:27:42    阅读次数:191
Remove Duplicates from Sorted List II 移除有序链表中的重复项之二
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-...
分类:其他好文   时间:2014-11-02 13:41:39    阅读次数:168
417条   上一页 1 ... 36 37 38 39 40 ... 42 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!