tantan的博客

Notes, ideas, and observations

思路类似归并排序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *next) : val(x), next(next) {}
* };
*/
class Solution {
public:
ListNode* mergeKLists(vector<ListNode*>& lists) {
ListNode newList;
ListNode*head=&newList;
while(true){
int min=-1,minval=0x3fffffff;
for(int i=0;i<lists.size();i++){
ListNode*l=lists[i];
if(l && l->val < minval){
min=i;
minval=l->val;
}
}
if(min<0)break;
head->next=lists[min];
lists[min]=lists[min]->next;
head=head->next;
}
head->next=nullptr;
return newList.next;
}
};

送分题

1
2
3
4
5
6
7
8
9
10
11
12
13
class Solution {
public:
char findTheDifference(string s, string t) {
map<char, int>count;
for(auto&&c:s){
count[c]++;
}
for(auto&&c:t){
count[c]--;
}
return find_if(count.begin(),count.end(),[&](auto it){return it.second!=0;})->first;
}
};

Oracle Apex怎么调用procedure

1
2
3
begin
ANALYSIS(6, 1000);
end;

Spring-doc OpenAPI 注解

@Operation @Response @Parameter

给出二叉树结构和节点的值列表, 将值填入二叉树中, 输出层次序遍历的结果

考点: 二叉树的直接后继

0%