You are viewing a single comment's thread. Return to all comments →
I used Stack to solve this problem.
java.util.Stack<Node> stack = new java.util.Stack<>(); if(head != null) { Node currentNode = head; while(currentNode!=null) { stack.push(currentNode); currentNode = currentNode.next; } while(!stack.isEmpty()) { System.out.println((stack.pop()).data); } }
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 →
I used Stack to solve this problem.