Created
April 21, 2018 09:08
-
-
Save Kishy-nivas/31e20152c2821dab638664d3b7c4234d 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 { | |
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