![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
链表
文章平均质量分 82
别哔哔好伐
安静的coder
展开
-
链表合并
设有两个无头结点的单链表,头指针分别为ha,hb,链中有数据域data,链域next,两链表的数据都按递增序存放,现要求将hb表归到ha表中,且归并后ha仍递增序,归并中ha表中已有的数据若hb中也有,则hb中的数据不归并到ha中,hb的链表在算法中不允许破坏。#include /// no have dead node ha and hb >>ha#includetypedef原创 2014-11-13 23:39:44 · 2177 阅读 · 2 评论 -
leetcode-21-Merge Two Sorted Lists
Merge Two Sorted ListsMerge 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.合原创 2015-07-02 23:03:46 · 627 阅读 · 0 评论 -
leetcode-203-Remove Linked List Elements
Remove Linked List ElementsRemove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4原创 2015-07-16 19:11:13 · 480 阅读 · 0 评论 -
leetcode-237-Delete Node in a Linked List
Delete Node in a Linked List Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and原创 2015-07-16 13:22:37 · 735 阅读 · 0 评论 -
反转单链表
反转单链表1. 用数组将单链表的值存储在数组里。方法简单,但浪费空间。2. 遍历链表,从第二个节点开始,将每个节点的next指向前一个节点。原链表的最后一个节点变为头节点。3. 遍历链表,除第一个节点外,将每一个节点依次插到第一个节点后面。最后将第一个节点插到最后。way 2 :ListNode* reverse_1(ListNode* head){ L原创 2015-07-20 14:40:40 · 494 阅读 · 0 评论 -
leetcode-234-Palindrome Linked List
Palindrome Linked List Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?判断链表是否为回文。空间复杂度O(n)。/** *原创 2015-07-19 11:39:12 · 408 阅读 · 0 评论 -
leetcode-160-Intersection of Two Linked Lists
Intersection of Two Linked ListsWrite a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 →原创 2015-07-25 09:28:22 · 557 阅读 · 0 评论 -
02-线性结构1 一元多项式的乘法与加法运算
02-线性结构1 一元多项式的乘法与加法运算 (20分)设计函数分别求两个一元多项式的乘积与和。输入格式:输入分2行,每行分别先给出多项式非零项的个数,再以指数递降方式输入一个多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。输出格式:输出分2行,分别以指数递降方式输出乘积多项式以及和多项式非零项的系数和指数。数字间以空格分隔,原创 2015-10-04 22:25:45 · 566 阅读 · 0 评论 -
leetcode-328-Odd Even Linked List
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in原创 2016-03-07 22:46:05 · 300 阅读 · 0 评论