1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; ...
分类:
其他好文 时间:
2020-03-20 10:48:21
阅读次数:
55
链接:https://leetcode-cn.com/problems/linked-list-cycle/ 给定一个链表,判断链表中是否有环。 为了表示给定链表中的环,我们使用整数 pos 来表示链表尾连接到链表中的位置(索引从 0 开始)。 如果 pos 是 -1,则在该链表中没有环。 示例 1 ...
分类:
其他好文 时间:
2020-03-20 00:43:32
阅读次数:
49
一、题目说明 题目142. Linked List Cycle II,判断一个链表是否有环,如果有返回环的第一个元素,否则返回NULL。 这个题目是 141. Linked List Cycle 的升级版本,难度是Medium! 二、我的解答 最直观的解答就是用一个unordered_map dp来 ...
分类:
其他好文 时间:
2020-03-19 21:52:56
阅读次数:
71
1、概述 是内存中不连续的存储区域,元素是游离存储的,每个元素会记录下一个元素的地址。 2、特点 查询元素慢; 增删元素快(针对于首尾元素,速度极快,一般是双链表); 3、图解 单向链表: 循环链表就是最后一个元素指向第一个元素地址; 双向链表: ...
分类:
其他好文 时间:
2020-03-18 22:07:44
阅读次数:
57
1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; ...
分类:
其他好文 时间:
2020-03-15 18:55:57
阅读次数:
53
1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; ...
分类:
其他好文 时间:
2020-03-15 18:52:06
阅读次数:
51
Given a non-negative integer represented as non-empty a singly linked list of digits, plus one to the integer. You may assume the integer do not conta ...
分类:
其他好文 时间:
2020-03-15 13:27:25
阅读次数:
48
链表中的下一个更大节点。题意是给一个linkedlist,请返回当前节点之后所有节点里面值最大的节点。注意最后一个节点之后因为没有其他节点了,所以返回0。例子, Example 1: Input: [2,1,5] Output: [5,5,0] Example 2: Input: [2,7,4,3, ...
分类:
其他好文 时间:
2020-03-14 11:14:08
阅读次数:
56
Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, ...
分类:
其他好文 时间:
2020-03-13 13:03:41
阅读次数:
52
将两个有序链表合并为一个新的有序链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(in ...
分类:
其他好文 时间:
2020-03-12 10:06:33
阅读次数:
47