LeetCode/Problems
LeetCode 206. Reverse Linked List
벤진[Benzene]
2020. 6. 1. 02:18
Problem:
Reverse a singly linked list.
Example:
Input: 1->2->3->4->5->NULL
Output: 5->4->3->2->1->NULL
-Summary-
1. Keep track of current / prev (copy the original list in the curr and prev)
2. Update and move the head (original)
3. Return prev
정답을 보니 recursive 하게 푸는 방법도 있었다.
모든 문제에 대한 저작권은 LeetCode 회사에 있습니다. [Copyright © 2020 LeetCode]