'''
- Leetcode problem: 206

- Difficulty: Easy

- Brief problem description:

    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?

- Solution Summary:

None Recursive Solution

- Used Resources:

--- Bo Zhou
'''


# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def reverseList(self, head):
        root = head
        pre = None
        while root:
            tmp = root.next
            root.next = pre
            pre = root
            root = tmp
        return pre
