public ListNode[] rehashing(ListNode[] hashTable) {
        // write your code here
        int capacity = hashTable.length * 2;
        ListNode[] ans = new ListNode[capacity];
        for (ListNode node : hashTable) {
            while (node != null) {
                int index = hashcode(node.val, capacity);
                if (ans[index] == null) {
                    ans[index] = new ListNode(node.val);
                } else {
                    ListNode p = ans[index];
                    ListNode prev = null;
                    while (p != null) {
                        prev = p;
                        p = p.next;
                    }
                    prev.next = new ListNode(node.val);
                }
                node = node.next;
            }
        }
        return ans;
    }