# -*- coding:utf-8 -*-
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None
from copy import deepcopy


class Solution:

    # 返回ListNode
    def reverseList(self, node):
        # write code here
        if not node or not node.next:
            return node
        prev = None
        while node:
            tmp = node.next
            node.next = prev
            prev = node
            node = tmp
        return prev

c7764e304ebfed2ef8281565dbbd6877dee9da9b
<mask token>

<mask token>


class Solution:
    <mask token>

<mask token>


class Solution:

    def reverseList(self, node):
        if not node or not node.next:
            return node
        prev = None
        while node:
            tmp = node.next
            node.next = prev
            prev = node
            node = tmp
        return prev

from copy import deepcopy


class Solution:

    def reverseList(self, node):
        if not node or not node.next:
            return node
        prev = None
        while node:
            tmp = node.next
            node.next = prev
            prev = node
            node = tmp
        return prev

# -*- coding:utf-8 -*-
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None
from copy import deepcopy


class Solution:

    # 返回ListNode
    def reverseList(self, node):
        # write code here
        if not node or not node.next:
            return node
        prev = None
        while node:
            tmp = node.next
            node.next = prev
            prev = node
            node = tmp
        return prev
