public ListNode mergeKLists(ListNode[] lists) {
        if (lists == null || lists.length == 0) {
            return null;
        }

        Stack<ListNode> s1 = new Stack<ListNode>();
        Stack<ListNode> s2 = new Stack<ListNode>();

        for (int i = 0; i < lists.length; i++) {
            s1.push(lists[i]);
        }

        while (true) {
            if(s1.size() == 1) {
                return s1.pop();
            }

            while(!s1.isEmpty()) {
                ListNode p1 = s1.pop();
                if(s1.isEmpty()) {
                    s2.push(p1);
                } else {
                    ListNode p2 = s1.pop();
                    s2.push(mergeTwoLists(p1, p2));
                }
            }

            Stack<ListNode> temp = s1;
            s1 = s2;
            s2 = temp;
        }
    }