Leetcode 598 Range Addition II
来源:互联网 发布:java void 编辑:程序博客网 时间:2024/06/07 07:51
Leetcode 598 Range Addition II
class Solution {public: //memory limit exceeded int maxCount(int m, int n, vector<vector<int>>& ops) { vector<int> colMatrix(n,0); vector<vector<int>> zeroMatrix(m,colMatrix); int maxCount = 0; //操作完之后统计与(0.0)元素相同的数 int row = 0; int col = 0; for(auto oneRow : ops) { row = oneRow[0]; col = oneRow[1]; for(int i = 0;i < row;i ++) { for(int j = 0;j < col;j ++) zeroMatrix[i][j] ++; } } for(int i = 0;i < m;i ++) { for(int j = 0;j < n;j ++) { if(zeroMatrix[i][j] == zeroMatrix[0][0]) maxCount ++; } } return maxCount; } //找到ops中每个pair(a,b)的最小值即可,然后maxcount就是a*b int maxCount2(int m, int n, vector<vector<int>>& ops) { if(ops.empty()) return m*n; int row = ops[0][0]; int col = ops[0][1]; for(auto oneRow : ops) { row = min(row,oneRow[0]); col = min(col,oneRow[1]); } return row * col; }};
阅读全文
0 0
- Leetcode 598 Range Addition II
- leetcode[Range Addition II]
- Range Addition II(leetcode)
- [leetcode]598. Range Addition II
- [leetcode]: 598. Range Addition II
- leetcode 598. Range Addition II
- [LeetCode]598. Range Addition II
- LeetCode 598. Range Addition II
- leetcode-598. Range Addition II
- leetcode 598. Range Addition II
- LeetCode-598. Range Addition II (Java)
- leetcode Range Addition II 范围相加
- 598. Range Addition II
- 598. Range Addition II
- 598. Range Addition II
- 598. Range Addition II
- 598. Range Addition II
- leetcode598. Range Addition II
- C语言编程计算输入文本空格数量常犯的无计算结果的问题解析
- 代码与生命
- html基础用法②——文档声明和META标签
- memcache服务器软件安装步骤
- C++的类(class)中带有指针(*)--(Boolan)
- Leetcode 598 Range Addition II
- vue 中使用echart3.0自适应文本框大小
- 【libevent】源码分析(4)--与event相关的一些函数和操作
- java技术面试之面试题大全
- javaWeb笔记之Cookie
- 文件打包、压缩及传输
- oracle索引和用户权限
- [noip2014]联合权值 题解
- 命令模式