题目 Reverse a singly linked list. Example: Input: 1 2 3 4 5 NULL Output: 5 4 3 2 1 NULL Follow up: A linked list can be reversed either iteratively or ...
分类:
其他好文 时间:
2018-10-14 11:36:02
阅读次数:
115
一、题目 1、审题 2、分析 给出一个链表,如果没有环则返回 null, 若存在环,返回环开始的节点。 二、解答 1、思路: 方法一、 ...
分类:
其他好文 时间:
2018-10-11 23:49:49
阅读次数:
165
141. Linked List Cycle (环形链表) 题目概述:判断一个链表中是否有环 思路 创建两个指针(快指针和慢指针),慢指针的移动方式为:单次移动一个结点;快指针的移动方式为:单次移动两个结点。如果快指针指向的结点和慢指针指向的结点相同(注:这里的结点指向了对象,所以直接通过==判断是 ...
分类:
其他好文 时间:
2018-10-11 22:01:19
阅读次数:
163
经典链表题找链表的中间节点 快慢指针 #include #include #include using namespace std; //Definition for singly-linked list. //Given a non-empty, singly linked list with h... ...
分类:
其他好文 时间:
2018-10-10 01:04:13
阅读次数:
139
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *///注意取模,和空集 ... ...
分类:
其他好文 时间:
2018-10-09 16:15:20
阅读次数:
135
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to ...
分类:
编程语言 时间:
2018-10-09 13:57:54
阅读次数:
264
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to ...
分类:
其他好文 时间:
2018-10-07 23:30:32
阅读次数:
291
https://leetcode.com/problems/linked-list-cycle-ii/discuss/44777/Concise-JAVA-solution-based-on-slow-fast-pointers fast slow, 刚开始全部初始化为0,当作起始点 ...
分类:
其他好文 时间:
2018-10-07 13:55:07
阅读次数:
145
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. Follow up: Can yo ...
分类:
其他好文 时间:
2018-10-06 14:36:01
阅读次数:
137
Given a linked list, swap every two adjacent nodes and return its head. Example: Note: Your algorithm should use only constant extra space. You may no ...
分类:
其他好文 时间:
2018-10-05 22:34:58
阅读次数:
193