
数据结构
Hu.先森
这个作者很懒,什么都没留下…
展开
-
数据结构——链表(有序链表合并2)
/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } };*/ class Solution { public: ListNode* Merge(ListNode* pHead1, ListNode* pHead2) { ...原创 2020-03-26 20:55:50 · 156 阅读 · 0 评论 -
数据结构——链表(输出链表的第k个节点)
题目描述 输入一个链表,输出该链表中倒数第k个结点。 struct ListNode { 3 int val; 4 struct ListNode *next; 5 ListNode(int x) : 6 val(x), next(NULL) { 7 } 8 };*/ 9 class Solution { 10 public: 11 ...原创 2020-03-26 15:23:19 · 363 阅读 · 0 评论 -
数据结构——链表(合并两个有序链表)
//1. 给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次。 //示例:输入: 1->1->2->3->3;输出: 1->2->3 ListNode* find(ListNode* head1,ListNode* head2) { ListNode* p1 = head1; ListNode* p2 = head2; ...原创 2020-03-26 12:26:07 · 376 阅读 · 0 评论 -
数据结构——创建并且遍历链表(C++)
#include <iostream> #include <cstdlib> #include <string> using namespace std; //定义一个结构体 typedef struct ListNode{ int value; struct ListNode* next; }ListNode; //创建n个链表 List...原创 2020-03-26 11:02:37 · 320 阅读 · 0 评论