题目:https://leetcode-cn.com/problems/set-matrix-zeroes/
class Solution {
public:
void setZeroes(vector& matrix) {
/*
*给定一个 m x n 的矩阵,如果一个元素为 0,
*则将其所在行和列的所有元素都设为 0。
*使用原地算法
*利用边界元素
*/
int m = matrix.size();
int n = matrix[0].size();
bool r = 0,c = 0;
for(int i = 0;i
关注
打赏
热门博文