You are viewing a single comment's thread. Return to all comments →
Here is my Java solution,
public static void reversePrint(SinglyLinkedListNode llist) { Stackstack=new Stack<>(); SinglyLinkedListNode current = llist; while(current!=null) { stack.push(current.data); current=current.next; } while (!stack.isEmpty()) { System.out.println(stack.pop()); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Print in Reverse
You are viewing a single comment's thread. Return to all comments →
Here is my Java solution,
public static void reversePrint(SinglyLinkedListNode llist) { Stackstack=new Stack<>(); SinglyLinkedListNode current = llist; while(current!=null) { stack.push(current.data); current=current.next; } while (!stack.isEmpty()) { System.out.println(stack.pop()); } } }