Given an m * n matrix M initialized with all 0's and several update operations.

Operations are represented by a 2D array, and each operation is represented by an array with two positive integers a and b, which means M[i][j] should be added by one for all 0 <= i < a and 0 <= j < b.

You need to count and return the number of maximum integers in the matrix after performing all the operations.

Example 1:

Input:
m = 3, n = 3
operations = [[2,2],[3,3]]
Output: 4
Explanation:
Initially, M =
[[0, 0, 0],
[0, 0, 0],
[0, 0, 0]] After performing [2,2], M =
[[1, 1, 0],
[1, 1, 0],
[0, 0, 0]] After performing [3,3], M =
[[2, 2, 1],
[2, 2, 1],
[1, 1, 1]] So the maximum integer in M is 2, and there are four of it in M. So return 4.

Note:

  1. The range of m and n is [1,40000].
  2. The range of a is [1,m], and the range of b is [1,n].
  3. The range of operations size won't exceed 10,000.

class Solution(object):
def maxCount(self, m, n, ops):
"""
:type m: int
:type n: int
:type ops: List[List[int]]
:rtype: int
"""
for o in ops:
m=min(o[0],m)
n=min(o[1],n)
return m*n

  

[LeetCode&Python] Problem 598. Range Addition II的更多相关文章

  1. 【leetcode_easy】598. Range Addition II

    problem 598. Range Addition II 题意: 第一感觉就是最小的行和列的乘积即是最后结果. class Solution { public: int maxCount(int ...

  2. [LeetCode] 598. Range Addition II 范围相加之二

    Given an m * n matrix M initialized with all 0's and several update operations. Operations are repre ...

  3. LeetCode: 598 Range Addition II(easy)

    题目: Given an m * n matrix M initialized with all 0's and several update operations. Operations are r ...

  4. 598. Range Addition II 矩阵的范围叠加

    [抄题]: Given an m * n matrix M initialized with all 0's and several update operations. Operations are ...

  5. 【LeetCode】598. Range Addition II 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

  6. LeetCode 598. Range Addition II (范围加法之二)

    Given an m * n matrix M initialized with all 0's and several update operations. Operations are repre ...

  7. 【leetcode】598. Range Addition II

    You are given an m x n matrix M initialized with all 0's and an array of operations ops, where ops[i ...

  8. 598. Range Addition II

    Given an m * n matrixMinitialized with all0's and several update operations. Operations are represen ...

  9. [LeetCode&Python] Problem 541. Reverse String II

    Given a string and an integer k, you need to reverse the first k characters for every 2k characters ...

随机推荐

  1. redis 管道原理

    命令行使用管道(命令以换行符分隔): (printf "PING\r\nPING\r\nPING\r\n"; sleep 1) | nc localhost 6379 redis ...

  2. MySQL批量修改字符集

    统一将字符字符集变成utf8_general_ci,已测试. DROP PROCEDURE IF EXISTS `chanageCharSet`; CREATE PROCEDURE `chanageC ...

  3. yii2入门安装 Windows7+wamp+yii2

    1.首先先具备环境,下载最新wamp(yii2需要php5.40以上版本的http://www.digpage.com/install.html) wamp下载http://pan.baidu.com ...

  4. 【JAVA】关于向上转型与向下转型

    向上转型: 子类引用的对象转换为父类类型称为向上转型.通俗地说就是是将子类对象转为父类对象.此处父类对象可以是接口 如果子类重写了父类的方法,就根据这个引用指向调用子类重写的这个方法,不是调用父类的, ...

  5. 技术宅学习Linux系统还是很有前途的

    老实说,我之所以入了Linux的坑,纯粹只是为了追我现在的男朋友,也就是技术宅.如果不是为了追我男朋友的话,我估计我这辈子都不会去接触linux.好吧,今天写一写过往事情,也是为了怀念当初追男友的一些 ...

  6. 【资料搜集】DirectX学习

    [网站推荐:]GameRes游资网-游戏开发者门户 http://www.gameres.com/ [基础知识:] <游戏编程>第一部 基础篇 - GameRes.com http://d ...

  7. Python pycharm 引入需要使用的包

    第一步 第二步 第三步

  8. zabbix安装部署(server部分)

    Linux下常用的系统监控软件有Nagios.Cacti.Zabbix.Monit等,这些开源的软件,可以帮助我们更好的管理机器,在第一时间内发现,并警告系统维护人员. 今天开始研究下Zabbix,使 ...

  9. 7.1 C++模板基本概念及语法 《C++模板与标准模板库》

    参考:http://www.weixueyuan.net/view/6398.html 总结: 模板是另一种代码重用机制. 需要设计的几个类,其功能都是一样的,仅仅只是需要操作的数据类型不同. 有更好 ...

  10. DevExpress WinForms使用教程:图表控件 - 内置深入查询

    [DevExpress WinForms v18.2下载] 在最新发布的DevExpress WinForms v18.2中,DevExpress WinForms和ASP.NET图表控件引入嵌套系列 ...