@Test public void testBuildLinkedList() { for (int i = 1; i < 20; i++) { Node cur = linkedList.buildLinkedList(i); Node p = cur; for (int j = 0; j < i; j++) { Assert.assertEquals(p.val,j); p = p.next; } Assert.assertEquals(null,p); } }
public Node buildLinkedList(int n) { Node root = new Node(0); Node pre = root; for (int i = 1; i < n; i++, pre = pre.next) { pre.next = new Node(i); } return root; }
ShuffleLinkedList { public Node buildLinkedList(int n) { Node root = new Node(0); Node pre = root; for (int i = 1; i < n; i++, pre = pre.next) { pre.next = new Node(i); } return root; } }
ShuffleLinkedList { public Node buildLinkedList(int n) { Node root = new Node(0); Node pre = root; for (int i = 1; i < n; i++, pre = pre.next) { pre.next = new Node(i); } return root; }  }
ShuffleLinkedList { public Node buildLinkedList(int n) { Node root = new Node(0); Node pre = root; for (int i = 1; i < n; i++, pre = pre.next) { pre.next = new Node(i); } return root; }  Node buildLinkedList(int n); Node shuffle(Node list); }
ShuffleLinkedList { public Node buildLinkedList(int n) { Node root = new Node(0); Node pre = root; for (int i = 1; i < n; i++, pre = pre.next) { pre.next = new Node(i); } return root; }  Node buildLinkedList(int n); Node shuffle(Node list);  }