// Hunter Schafer, CSE 143 // An example of a ListNode manipulation problem public class ListNodeExamples { public static void main(String[] args) { ListNode dummy = new ListNode(-1); // Problem 2 // Before: // list -> 10 -> 20 // After: // list -> 30 -> 10 -> 20 ListNode list = new ListNode(10, new ListNode(20)); // Original solution // ListNode temp = new ListNode(30); // temp.next = list; // list = temp; // More condensed solution list = new ListNode(30, list); // This is similar to // int x = 5; // x = x + 1; } }