# https://leetcode.com/problems/reverse-linked-list/

# Definition for singly-linked list.
class ListNode:
     def __init__(self, x):
         self.val = x
         self.next = None

class Solution:
    # @param {ListNode} head
    # @return {ListNode}
    def reverseList(self, head):
        last, current = None, head
        while current:
            next = current.next
            current.next = last
            last = current
            current = next
        return last

add rll