Futuroscopewewe
Futuroscopewewe
全部文章
分类
题解(10)
归档
标签
去牛客网
登录
/
注册
Futuroscopewewe的博客
全部文章
(共10篇)
题解 | #判断一棵二叉树是否为搜索二叉树和完全二叉树#
/** * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ class Solution { public: /** * ...
2021-08-30
0
281
题解 | #复杂链表的复制#
克隆结点->克隆随机指针->奇偶链表分离 以下cur均用在原来的结点上,而克隆得到的结点都用的是temp或clone_cur或clone_head。 // 克隆, 让 A->B 变成 A->A'->B->B' void CloneNode(RandomListN...
2021-08-22
0
265
题解 | #接雨水问题#
单调栈法: class Solution { public: /** * max water * @param arr int整型vector the array * @return long长整型 */ long long maxWater(...
2021-08-11
0
330
题解 | #链表内指定区间反转#
区间分为[...]->[prev]->[h]->[...]->[t]->[tail]->[...]要反转的是h和t之间的节点(包括h和t) // 反转区间[head, tail] pair<ListNode*, ListNode*> reverseLi...
2021-08-09
0
328
题解 | #判断一个链表是否为回文结构#
反转链表的方式: struct ListNode { int val; struct ListNode *next; explicit ListNode(int v) : val(v) , next(nullptr) {} }; ListNode* reverseList(ListN...
2021-08-09
0
370
题解 | #滑动窗口的最大值#
暴力: vector<int> maxInWindows(const vector<int>& num, unsigned int size) { if (num.size() < size || size == 0) return { }; vector<...
2021-08-04
0
270
题解 | #LFU缓存结构设计#
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstdio> #include <vector> #include <string> #include <queue&g...
2021-08-04
0
396
题解 | #字符串出现次数的TopK问题#
using psi = pair<string, int>; // 自定义大顶堆 struct cmp { bool operator()(const psi& p1, const psi& p2) { if (p1.second != p2.second) ...
2021-07-28
0
364
题解 | #合并k个已排序的链表#
所有调试代码 struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} }; // 合并两个链表 ListNode* mergeTwoLists(ListNode* head1,...
2021-07-27
0
318
题解 | #在旋转过的有序数组中寻找目标值#
int search(vector<int>& nums, int target) { int len = nums.size(); if (len == 0) return -1; int i = 0; int j = len - 1; while (i &...
2021-07-27
0
278