Tag: 206 Reverse Linked List
-
LeetCode: 206 Reverse Linked List
•
Given the head of a singly linked list, reverse the list, and return the reversed list. Example: Input: head = [1,2,3,4,5] Output: [5,4,3,2,1] Example: Input: head = [1,2] Output: [2,1] Example: Input: head = [] Output: [] 问题 给定一个单链表的头节点,将链表反转,并返回反转后的链表。 解决方案 1 迭代法 Approach 1 / 方法 1 This solution uses…