Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 题意:对k个有序的链表进行归并排序.并分析其复杂度. /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(N…
problem: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Tags Divide and Conquer Linked List Heap 合并K个已序单链表 thinking: (1)题目没有要求不能够新开ListNode,所以暴力破解法:提取K个list的keyword.排序.新建结点插入.这样的情况对原list是否排好序没有要求. 排…
A - Poisonous Cookies 题意 有\(A\)个能解毒的普通饼干,\(B\)个能解毒的美味饼干,\(C\)个有毒的美味饼干,求最多能吃多少个美味饼干,每次吃完有毒的饼干后要解毒后才能继续吃. 题解 输出\(\text{min(A + B + 1, C) + B}\)即可. 代码 #include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >…