Created
October 17, 2018 05:21
-
-
Save tech-cow/4db6d5e3bf561de7a70e7c38e4478c63 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # n1 -> n2 -> n3 | |
| Class Node(self): | |
| def __init__(self, val): | |
| self.next = next | |
| self.val = val | |
| def reverse_list(self, head): | |
| prev = None | |
| cur = head | |
| while cur: | |
| next = cur.next | |
| cur.next = prev | |
| prev = cur | |
| cur = next | |
| return head | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment