会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
15
16
17
18
19
20
21
22
23
···
38
下一页
2020年4月9日
213. 打家劫舍 II
摘要: 1 class Solution 2 { 3 public: 4 int rob(vector<int>& nums) 5 { 6 int n = nums.size(); 7 if(n == 0) return 0; 8 else if(n == 1) return nums[0]; 9 else
阅读全文
posted @ 2020-04-09 13:48 Jinxiaobo0509
阅读(153)
评论(0)
推荐(0)
2020年4月8日
918. 环形子数组的最大和
摘要: 1 //数组是连续的 2 class Solution 3 { 4 public: 5 int maxSubarraySumCircular(vector<int>& A) 6 { 7 // 单调队列 8 int n = A.size(); 9 deque<int> q; 10 for(int i
阅读全文
posted @ 2020-04-08 22:50 Jinxiaobo0509
阅读(174)
评论(0)
推荐(0)
239. 滑动窗口最大值
摘要: 1 class Solution 2 { 3 public: 4 vector<int> maxSlidingWindow(vector<int>& nums, int k) 5 { 6 vector<int> res; 7 deque<int> q; 8 for(int i = 0;i < num
阅读全文
posted @ 2020-04-08 16:29 Jinxiaobo0509
阅读(126)
评论(0)
推荐(0)
42. 接雨水
摘要: 1 //自底向上层层叠加 2 class Solution 3 { 4 public: 5 int trap(vector<int>& height) 6 { 7 int res = 0; 8 stack<int> stk; 9 10 for(int i = 0;i < height.size();
阅读全文
posted @ 2020-04-08 16:04 Jinxiaobo0509
阅读(111)
评论(0)
推荐(0)
84. 柱状图中最大的矩形
摘要: 1 class Solution 2 { 3 public: 4 int largestRectangleArea(vector<int>& heights) 5 { 6 int n = heights.size(); 7 vector<int> left(n),right(n); 8 9 //用单
阅读全文
posted @ 2020-04-08 15:27 Jinxiaobo0509
阅读(115)
评论(0)
推荐(0)
2020年4月7日
32. 最长有效括号
摘要: 1 //括号序列合法 <==> 所有前缀和>=0,且总和等于0 2 3 // start当前枚举的这一段的开头 4 // cnt前缀和 5 // (=1 6 // )=-1 7 // 1、cnt<0 => start = i + 1,cnt = 0 8 // 2、cnt>0 => 继续做 9 //
阅读全文
posted @ 2020-04-07 22:43 Jinxiaobo0509
阅读(193)
评论(0)
推荐(0)
括号序列合法
摘要: 括号序列合法 <==> 所有前缀和>=0,且总和等于0
阅读全文
posted @ 2020-04-07 22:41 Jinxiaobo0509
阅读(178)
评论(0)
推荐(0)
2020年4月4日
76. 最小覆盖子串
摘要: 1 class Solution 2 { 3 public: 4 string minWindow(string s, string t) 5 { 6 unordered_map<char,int> hash; 7 for(auto c : t) hash[c]++; 8 int cnt = has
阅读全文
posted @ 2020-04-04 23:01 Jinxiaobo0509
阅读(185)
评论(0)
推荐(0)
211. 添加与搜索单词 - 数据结构设计
摘要: 1 class WordDictionary 2 { 3 bool is_end; //是否以该单词结尾 4 WordDictionary* son[26]; //该节点儿子的个数 5 6 public: 7 WordDictionary() 8 { 9 is_end = false; 10 for
阅读全文
posted @ 2020-04-04 20:36 Jinxiaobo0509
阅读(396)
评论(0)
推荐(0)
210. 课程表 II
摘要: 1 class Solution 2 { 3 vector<int> res; 4 public: 5 vector<int> findOrder(int numCourses, vector<vector<int>>& prerequisites) 6 { 7 vector<vector<int>
阅读全文
posted @ 2020-04-04 19:19 Jinxiaobo0509
阅读(151)
评论(1)
推荐(0)
上一页
1
···
15
16
17
18
19
20
21
22
23
···
38
下一页
公告