小熊_008
小熊_008
全部文章
分类
题解(8)
归档
标签
去牛客网
登录
/
注册
小熊_008的博客
全部文章
(共8篇)
题解 | #接雨水问题#
双指针 class Solution { public: /** * max water * @param arr int整型vector the array * @return long长整型 */ long long maxWater(ve...
2021-08-20
0
503
题解 | #回文字符串#
dp[i][j]的意义:在子串 s[i...j] 中,最长的回文子串长度。 #include <bits/stdc++.h> using namespace std; int longestPalindromeSubseq(const string& str) { i...
2021-08-19
0
577
题解 | #按之字形顺序打印二叉树# C++
/* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(N...
2021-07-23
0
560
题解 | #子数组的最大累加和问题#
要求空间复杂度为 O(1),反而是个提示,因为这意味着只能用几个变量记录值。很明显一个记录是不可能的,所以先定义两个 // 使用两个临时变量记录 int maxSum = arr[0]; int tmpSum = arr[0]; 然后,时间复杂度是 O(n),以为着用的 只能是一重循环关键: 当前...
2021-07-14
0
496
题解 | #最长无重复子数组#C++ unordered_map 解决
class Solution { public: /** * * @param arr int整型vector the array * @return int整型 */ int maxLength(vector<int>&...
2021-07-13
4
814
题解 | #两个链表生成相加链表#
利用栈求解 /** * struct ListNode { * int val; * struct ListNode *next; * }; */ class Solution { public: /** * * @param head1 Lis...
2021-07-09
0
493
题解 | #缺失数字#
二分: class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 找缺失数字 * @param a int整型vector 给定的数字串 * @return...
2021-07-06
1
722
题解 | #最小的K个数#
class Solution { public: void heap_min(vector<int>& tree, int i){ if (tree.size() <= 1) { return; } ...
2021-07-05
0
556