leetcode 304. Range Sum Query 2D
来源:互联网 发布:linux自动化部署工具 编辑:程序博客网 时间:2024/05/24 05:32
class NumMatrix(object): def __init__(self, matrix): """ :type matrix: List[List[int]] """ if not matrix: self.table = None return self.table = [ [ 0 for i in range(len(matrix[0])+1) ] for j in range(len(matrix)+1) ] self.table[0][0] = matrix[0][0] for i in range(1,len(matrix)+1,1): for j in range(1,len(matrix[0])+1,1): self.table[i][j] = self.table[i-1][j] + self.table[i][j-1]-self.table[i-1][j-1] + matrix[i-1][j-1] def sumRegion(self, row1, col1, row2, col2): """ :type row1: int :type col1: int :type row2: int :type col2: int :rtype: int """ if not self.table: return None else: return self.table[row2+1][col2+1] + self.table[row1][col1] -\ self.table[row2+1][col1] - self.table[row1][col2+1]
阅读全文
0 0
- leetcode 304. Range Sum Query 2D
- leetcode 304. Range Sum Query 2D
- [LeetCode]304. Range Sum Query 2D
- [leetcode]304. Range Sum Query 2D
- Leetcode 304. Range Sum Query 2D
- [Leetcode] 304. Range Sum Query 2D
- leetcode 304.Range Sum Query 2D
- leetcode 304. Range Sum Query 2D
- leetcode 304. Range Sum Query 2D
- [Leetcode]Range Sum Query 2D - Immutable
- Leetcode Range Sum Query 2D - Immutable
- LeetCode Range Sum Query 2D - Immutable
- [Leetcode]Range Sum Query 2D - Immutable
- Leetcode Range Sum Query 2D - Immutable
- Leetcode: Range Sum Query 2D - Immutable
- Leetcode: Range Sum Query 2D - Immutable
- leetcode:Range Sum Query 2D - Immutable
- LeetCode|Range Sum Query 2D - Immutable
- JavaWeb中JSP的基本语法和隐含对象
- leetcode 316. Remove Duplicate Letters
- vue中点击button会刷新页面
- Linux文件I/O概述
- 什么是视图
- leetcode 304. Range Sum Query 2D
- java--set
- Android之屏幕方向|显示方式|Activity重建问题|横竖屏切换不同的布局
- add-apt-repository PPA
- 利用document.implementation.createHTMLDocument创建新的document
- Unity通过UGUI的Slider调整物体颜色
- struts2标签获取parameter,request,session,application中的值
- Thread2(多线程)再接再厉ヾ(◍°∇°◍)ノ゙
- Android启动页解决攻略最终版