Skip to content

Latest commit

 

History

History
58 lines (41 loc) · 1.27 KB

0206-reverse-linked-list.adoc

File metadata and controls

58 lines (41 loc) · 1.27 KB

206. Reverse Linked List

{leetcode}/problems/reverse-linked-list/[LeetCode - Reverse Linked List^]

递归需要加强一下,反转链表的递归细节再推敲推敲。

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 recursively. Could you implement both?

思路分析

{image_attr}
一刷
link:{sourcedir}/_0206_ReverseLinkedList.java[role=include]
二刷
link:{sourcedir}/_0206_ReverseLinkedList_2.java[role=include]

思考题

可以尝试一下递归!

另外,思考一下如何通过传参来简化代码。