classSolution { public: /** * @param lists: a list of ListNode * @return: The head of one sorted list. */ ListNode *mergeKLists(vector<ListNode *> &lists){ // write your code here ListNode *root = NULL, *back_node = NULL;
while (true) { int min = std::numeric_limits<int>::max(); vector<ListNode *>::iterator min_iter = lists.end(); for (auto iter = lists.begin(); iter != lists.end(); ++iter) { ListNode *cur_node = *iter; if (cur_node != NULL && cur_node->val < min) { min = cur_node->val; min_iter = iter; } }