Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.