Created
June 26, 2014 15:36
-
-
Save SeanPONeil/fc56ae2e77491c32ebfa 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
class Node { | |
char data; | |
Node next; | |
} | |
static Node reverse(Node root){ | |
Node reverseRoot = null; | |
while(root != null) { | |
Node next = root.next; | |
root.next = reverseRoot; | |
reverseRoot = root; | |
root = next; | |
} | |
return reverseRoot; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment