首页 > 其他 > 详细

Leetcode 73

时间:2018-10-23 17:17:54      阅读:114      评论:0      收藏:0      [点我收藏+]
class Solution {
public:
    void setZeroes(vector<vector<int>>& matrix) {
        vector<vector<int>> store;
        int m = matrix.size();
        int n = matrix[0].size();
        for(int i=0;i < m;i++){
            for(int j=0;j < n;j++){
                if(matrix[i][j] == 0){
                    vector<int> temp;
                    temp.push_back(i);
                    temp.push_back(j);
                    store.push_back(temp);
                    temp.clear();
                }
            }
        }
        for(int i=0;i < store.size();i++){
            int a = store[i][0];
            int b = store[i][1];
            for(int j=0;j < m;j++) matrix[j][b] = 0;
            for(int j=0;j < n;j++) matrix[a][j] = 0;
        }
    }
};

 

Leetcode 73

原文:https://www.cnblogs.com/cunyusup/p/9837488.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!