class Solution(object):
def reverseList(self, head):
pre=None
temp=ListNode()
while head:
temp=head.next
head.next=pre
pre=head
head=temp
return pre
class Solution(object):
def reverseList(self, head):
pre=None
temp=ListNode()
while head:
temp=head.next
head.next=pre
pre=head
head=temp
return pre