asto18089
asto18089
全部文章
分类
题解(10)
归档
标签
去牛客网
登录
/
注册
asto18089的博客
全部文章
(共25篇)
题解 | #序列化二叉树#
class Solution { public: char* Serialize(TreeNode* root) { ...
C++
二叉树
链表
2022-09-07
0
276
题解 | #滑动窗口的最大值#
class Solution { public: vector<int> maxInWindows(const vector<int>& nums, int&n...
C++
单调队列
2022-09-06
0
324
题解 | #有效括号序列#
#include <stack> class Solution { public: bool isValid(string s) { &nbs...
栈
C++
2022-07-14
0
258
题解 | #链表中环的入口结点#
class Solution { public: ListNode* EntryNodeOfLoop(ListNode* pHead) { &...
链表
C++
2022-07-14
0
271
题解 | #合并两个有序的数组#
class Solution { public: void merge(int A[], int m, int B[], int n) { &...
C++
数组
双指针
2022-07-13
1
236
题解 | #连续子数组的最大和#
#include <algorithm> class Solution { public: int FindGreatestSumOfSubArray(vector<int> ...
C++
动态规划
2022-07-13
0
198
题解 | #连续子数组最大和(ACM版本)#
很巧妙的解决方法,也不是什么动态规划,只要想明白了这种子数组的出现规律就很好明白。 32位int塞不下某些数据,需要用64位long。 #include <vector> #include <climits> using namespace std; int main()...
C++
2022-01-12
0
505
题解 | #两数之和#
很经典的一道unordered_map题。 public: /** * * @param numbers int整型vector * @param target int整型 * @return int整型vector */ ve...
C++
2022-01-12
0
387
题解 | #寻找第K大#
快速选择(Quickselect)算法,快速排序的近亲。C++ STL的nth_element正是这个功能。 时间复杂度O(N),空间复杂度O(1),题目的O(NlogN)有问题。 public: int findKth(vector<int> a, int n, int K) ...
C++
2022-01-12
0
279
题解 | #最小的K个数#
快速选择(Quickselect)算法,C++ STL的nth_element正是这个。 平均时间复杂度O(n),空间复杂度O(1)。 public: vector<int> GetLeastNumbers_Solution(vector<int> input, in...
C++
2022-01-12
0
297
首页
上一页
1
2
3
下一页
末页