Exemple #1
0
 @Test
 public void SortList() throws Exception {
   ListNode n1 = new ListNode(1);
   ListNode n2 = new ListNode(2);
   ListNode n3 = new ListNode(3);
   ListNode n4 = new ListNode(4);
   ListNode n5 = new ListNode(5);
   ListNode n6 = new ListNode(6);
   n6.next = n5;
   n5.next = n4;
   n4.next = n3;
   n3.next = n2;
   n2.next = n1;
   SortList s = new SortList();
   ListNode head = s.sortList(n6);
 }
  @Test
  public void testReverseBetween() throws Exception {
    ListNode n1 = new ListNode(1);
    ListNode n2 = new ListNode(2);
    ListNode n3 = new ListNode(3);
    ListNode n4 = new ListNode(4);
    ListNode n5 = new ListNode(5);
    n1.next = n2;
    n2.next = n3;
    n3.next = n4;
    n4.next = n5;

    ReverseLinkedList2 s = new ReverseLinkedList2();
    ListNode head = s.reverseBetween(n1, 2, 4);
  }