SHARE
TWEET

Untitled

a guest Sep 18th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Solution:
  2.     def reverseList(self, head: ListNode) -> ListNode:
  3.         return self.helper(head, None)
  4.    
  5.     def helper(self, node: ListNode, prev: ListNode) -> ListNode:
  6.         if not node:
  7.             return prev
  8.         curr = node.next
  9.         node.next = prev
  10.         prev = node
  11.         return self.helper(curr, prev)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top