菜菜子不想再菜了
菜菜子不想再菜了
全部文章
分类
归档
标签
去牛客网
登录
/
注册
菜菜子不想再菜了的博客
全部文章
(共84篇)
题解 | #逆波兰表达式求值#
#include <stack> class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param tokens string字符串vect...
2024-09-11
0
95
题解 | #设计LFU缓存结构#
static const auto __ = [] { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); return nullptr; } (); struct cell { int count{1};...
2024-09-03
0
101
题解 | #设计LRU缓存结构#
哈希表:利用查找O(1)特性,用于记录key对应的键值对在链表中的位置,用指针表示。双向链表:利用插入和删除操作的O(1)特性。用于模拟缓存,当哈希表给出了操作的位置,就可以直接调整链表结点的指针从而实现O(1)的插入和删除。 class Solution { private: int ...
2024-08-31
0
109
题解 | #顺时针旋转矩阵#
先转置,再水平翻转即可 class Solution { public: vector<vector<int> > rotateMatrix(vector<vector<int> >& mat, int n) { f...
2024-08-30
0
93
题解 | #旋转数组#
直接法 #include <vector> class Solution { public: vector<int> solve(int n, int m, vector<int>& a) { m = m % n; ...
2024-08-30
0
112
题解 | #主持人调度(二)#
本质上是看一组区间数组中的相交数组的个数。 static const auto io_sync_off = []() { // turn off sync std::ios::sync_with_stdio(false); // untie in/out streams ...
2024-08-29
0
92
题解 | #盛水最多的容器#
跳过指针移动过程中经过的比该循环初始时的值还要小的位置,这些位置不可能是最大容量,因为底面长度和边长都在缩短。 static const auto io_sync_off = []() { std::ios::sync_with_stdio(false); //关闭输入输出 std:...
2024-08-29
0
92
题解 | #盛水最多的容器#
双指针:从两头向中间,指针移动过程中跳过比上一步经过的值小的位置,因为只需要求最大值即可。 #include <algorithm> #include <vector> class Solution { public: int Area(vector<int...
2024-08-29
0
97
题解 | #最长无重复子数组#
#include <unordered_map> class Solution { public: int maxLength(vector<int>& arr) { unordered_map<int, int> hash; ...
2024-07-26
0
147
题解 | #合并区间#
我算是明白了,手搓快排是过不了的,唯有标准库sort /** * struct Interval { * int start; * int end; * Interval(int s, int e) : start(start), end(e) {} * }; */ static ...
2024-07-24
0
150
首页
上一页
1
2
3
4
5
6
7
8
9
下一页
末页