03 2021 档案

152. 乘积最大子数组
摘要:常规解法: DP 求数组中子区间的最大乘积,对于乘法,我们需要注意,负数乘以负数,会变成正数,所以解这题的时候我们需要维护两个变量,当前的最大值,以及最小值,最小值可能为负数,但没准下一步乘以一个负数,当前的最大值就变成最小值,而最小值则变成最大值了。 class Solution { public 阅读全文

posted @ 2021-03-26 10:25 hannah_id 阅读(98) 评论(0) 推荐(0)

232. 用栈实现队列
摘要:class MyQueue { stack<int> inStack, outStack; void in2out() { while(inStack.size()) { outStack.push(inStack.top()); inStack.pop(); } } public: /** Ini 阅读全文

posted @ 2021-03-05 09:46 hannah_id 阅读(67) 评论(0) 推荐(0)

994. 腐烂的橘子
摘要:class Solution { int cnt; int dis[12][12]; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; public: int orangesRotting(vector<vector<int>>& grid) 阅读全文

posted @ 2021-03-03 10:45 hannah_id 阅读(78) 评论(0) 推荐(0)

导航