Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]:
- if head==None or head.next==None:
- return head
- def change(first,second):
- if second.next==None:
- second.next=first
- return second
- else:
- t=change(second,second.next)
- second.next=first
- return t
- head=change(None,head)
- return head
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement