(SinglyLinkedNode newHead)
| 64 | } |
| 65 | |
| 66 | private static void printOutput(SinglyLinkedNode newHead) { |
| 67 | System.out.print("["); |
| 68 | do { |
| 69 | System.out.print(newHead.val); |
| 70 | newHead = newHead.next; |
| 71 | if (newHead != null) { |
| 72 | System.out.print(","); |
| 73 | } |
| 74 | } while(newHead != null); |
| 75 | System.out.println("]"); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Given the head of a linked list, rotate the list to the right by k places. |