206. Reverse Linked List
Reverse a singly linked list.
Example:
Follow up:
A linked list can be reversed either iteratively or recursively. Could you implement both?
解题要点:
设置一个为null的新节点,遍历旧链表,交换顺序存到新节点,并返回它。
Last updated
Was this helpful?
Reverse a singly linked list.
Example:
Follow up:
A linked list can be reversed either iteratively or recursively. Could you implement both?
设置一个为null的新节点,遍历旧链表,交换顺序存到新节点,并返回它。
Last updated
Was this helpful?