Skip to content

Instantly share code, notes, and snippets.

@Kishy-nivas
Created April 21, 2018 09:08
Show Gist options
  • Save Kishy-nivas/31e20152c2821dab638664d3b7c4234d to your computer and use it in GitHub Desktop.
Save Kishy-nivas/31e20152c2821dab638664d3b7c4234d to your computer and use it in GitHub Desktop.
class Node {
int data;
Node next;
Node prev;
}
Node Reverse(Node head) {
if(head == null) return null;
Node temp;
Node curr = head;
Node prev = null;
while(curr != null){
temp = curr.next;
curr.next = curr.prev;
curr.prev = temp;
prev = curr;
curr = temp;
}
return prev;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment