Skip to content

Instantly share code, notes, and snippets.

@stanley-shi
Created July 23, 2014 03:13
Show Gist options
  • Save stanley-shi/23e56ebfc09781801cb0 to your computer and use it in GitHub Desktop.
Save stanley-shi/23e56ebfc09781801cb0 to your computer and use it in GitHub Desktop.
RevertLinkedList
public Class RevertLinkedList{
public static class LinkedNode{
int data;
LinkedNode next;
}
public LinkedNode revert(LinkedNode head){
LinkedNode result = null;
while(head!=null){
LinkedNode tmp=head.next;
head.next=result;
result = head;
head=tmp;
}
return result;
}
}
@stanley-shi
Copy link
Author

This is purely an interview question;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment