Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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: Optional[ListNode]) -> Optional[ListNode]:
- l1= None
- current = head
- while current:
- nex = current.next
- current.next = l1
- l1=current
- current = nex
- return l1
Advertisement
Add Comment
Please, Sign In to add comment