Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.math.*;
- import java.security.*;
- import java.text.*;
- import java.util.*;
- import java.util.concurrent.*;
- import java.util.regex.*;
- // Complete the reversePrint function below.
- /*
- * For your reference:
- *
- * SinglyLinkedListNode {
- * int data;
- * SinglyLinkedListNode next;
- * }
- *
- */
- static void reversePrint(SinglyLinkedListNode head) {
- SinglyLinkedListNode foward = null;
- SinglyLinkedListNode prev = null;
- SinglyLinkedListNode current = head;
- while(current!=null){
- foward = current.next;
- current.next = prev;
- prev = current;
- current = foward;
- }
- while(prev!=null){
- System.out.println(prev.data);
- prev =prev.next;
- }
- }
- private static final Scanner scanner = new Scanner(System.in);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement