lintcode-矩阵归零
来源:互联网 发布:linux有什么认证 编辑:程序博客网 时间:2024/04/30 20:06
package bd_algo;import java.util.ArrayList;/** * Created by Administrator on 2017/8/29. */class MyPoint { int x; int y; MyPoint(int x, int y) { this.x = x; this.y = y; }}public class setZero { public static void main(String[] args) { } public void setZeroes(int[][] matrix) { // write your code here if (matrix == null || matrix.length == 0) return; int rows = matrix.length; int cols = matrix[0].length; ArrayList<MyPoint> points = new ArrayList<>(); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { if (matrix[i][j] == 0) { points.add(new MyPoint(i, j)); } } } for (MyPoint point : points) { int x = point.x; int y = point.y; for (int i = 0; i < cols; i++) { matrix[x][i] = 0; } for (int i = 0; i < rows; i++) { matrix[i][y] = 0; } } }}
阅读全文
0 0
- LintCode-矩阵归零
- LintCode: 矩阵归零
- 矩阵归零-LintCode
- lintcode-矩阵归零
- lintcode-矩阵归零-162
- LintCode 162-矩阵归零
- [Lintcode] Set Matrix Zeroes矩阵归零
- lintcode刷题——矩阵归零
- 矩阵归零
- 矩阵归零
- 矩阵归零
- 矩阵归零
- 矩阵归零
- 矩阵归零
- 矩阵归零
- Java实现-矩阵归零
- 矩阵归零消减序列和
- 【Openjudge】矩阵归零消减序列和
- 数组去重
- android 解决滑动冲突的外部拦截法
- linux zip命令
- HDU 2669Romantic(扩展欧几里德裸题)
- 文本操作(2)——sort
- lintcode-矩阵归零
- 微信公众号平台登陆-你已授权登陆过XXXX
- 执行Oracle中的函数wm_concat报错oracle wmsys.wm_concat ORA-00932: 数据类型不一致: 应为 -, 但却获得 CLOB
- 移动端不同尺寸下的适陪应
- 线程同步
- vue
- 2016
- springmvc控制器controller单例问题
- hdu1498二分图最小顶点覆盖