Search in sources :

Example 1 with ListNode

use of com.fishercoder.common.classes.ListNode in project Leetcode by fishercoder1534.

the class _328Test method test1.

@Test
public void test1() {
    node = new ListNode(1);
    node.next = new ListNode(2);
    node.next.next = new ListNode(3);
    node.next.next.next = new ListNode(4);
    node.next.next.next.next = new ListNode(5);
    expected = new ListNode(1);
    expected.next = new ListNode(3);
    expected.next.next = new ListNode(5);
    expected.next.next.next = new ListNode(2);
    expected.next.next.next.next = new ListNode(4);
    assertEquals(expected, test.oddEvenList(node));
}
Also used : ListNode(com.fishercoder.common.classes.ListNode) Test(org.junit.Test)

Example 2 with ListNode

use of com.fishercoder.common.classes.ListNode in project Leetcode by fishercoder1534.

the class _445Test method test1.

@Test
public void test1() {
    ListNode l1 = LinkedListUtils.contructLinkedList(new int[] { 7, 2, 4, 3 });
    ListNode l2 = LinkedListUtils.contructLinkedList(new int[] { 5, 6, 4 });
    ListNode expected = LinkedListUtils.contructLinkedList(new int[] { 7, 8, 0, 7 });
    assertEquals(expected, test.addTwoNumbers(l1, l2));
}
Also used : ListNode(com.fishercoder.common.classes.ListNode) Test(org.junit.Test)

Example 3 with ListNode

use of com.fishercoder.common.classes.ListNode in project Leetcode by fishercoder1534.

the class _445Test method test2.

@Test
public void test2() {
    ListNode l1 = LinkedListUtils.contructLinkedList(new int[] { 7, 2, 4, 3 });
    ListNode l2 = LinkedListUtils.contructLinkedList(new int[] { 5, 6, 4 });
    ListNode expected = LinkedListUtils.contructLinkedList(new int[] { 7, 8, 0, 7 });
    assertEquals(expected, solution2.addTwoNumbers(l1, l2));
}
Also used : ListNode(com.fishercoder.common.classes.ListNode) Test(org.junit.Test)

Example 4 with ListNode

use of com.fishercoder.common.classes.ListNode in project Leetcode by fishercoder1534.

the class _445Test method test3.

@Test
public void test3() {
    ListNode l1 = LinkedListUtils.contructLinkedList(new int[] { 5 });
    ListNode l2 = LinkedListUtils.contructLinkedList(new int[] { 5 });
    ListNode expected = LinkedListUtils.contructLinkedList(new int[] { 1, 0 });
    assertEquals(expected, solution2.addTwoNumbers(l1, l2));
}
Also used : ListNode(com.fishercoder.common.classes.ListNode) Test(org.junit.Test)

Example 5 with ListNode

use of com.fishercoder.common.classes.ListNode in project Leetcode by fishercoder1534.

the class _725Test method test3.

@Test
public void test3() {
    root = LinkedListUtils.contructLinkedList(new int[] { 1, 2, 3 });
    k = 5;
    actual = solution2.splitListToParts(root, k);
    for (ListNode head : actual) {
        ListNode.printList(head);
    }
}
Also used : ListNode(com.fishercoder.common.classes.ListNode) Test(org.junit.Test)

Aggregations

ListNode (com.fishercoder.common.classes.ListNode)26 Test (org.junit.Test)10 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 PriorityQueue (java.util.PriorityQueue)1