tantan的博客

Notes, ideas, and observations

#Spring 中 Filter 和 Interceptor 的区别

Filter 和 Interceptor 都可以实现对请求的拦截

根据排序的中间结果判断使用的插入排序还是堆排序, 并给出下一轮迭代的中间结果

堆排序: 先逐步构造一个大顶堆, 再每次从堆中取出最大的元素放到堆后面

寻找最长公共后缀

注意: 边界情况: 两条链没有交集, 其中一条链是另一条链的子链

思路类似归并排序

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%