#include<vector>
using namespace std;
class Solution {
public:voidsetZeroes(vector<vector<int>>& matrix){
bool firstRowHasZero = false;
bool firstColumnHasZero = false;//check the first column for(int i =0; i < matrix.size();++i){if(matrix[i][0]==0){
firstColumnHasZero = true;break;}}//check the first rowfor(int j =0; j < matrix[0].size();++j){if(matrix[0][j]==0){
firstRowHasZero = true;break;}}//record the info in the first column and first rowfor(int i =0; i < matrix.size(); i++){for(int j =0; j < matrix[i].size();++j)if(matrix[i][j]==0){
matrix[i][0]=0;
matrix[0][j]=0;}}//start to set zero for vector from first row and frist columnfor(int i =1; i < matrix.size(); i++){if(matrix[i][0]==0){for(int j =0; j < matrix[i].size(); j++)
matrix[i][j]=0;}}for(int j =1; j < matrix[0].size(); j++){if(matrix[0][j]==0){for(int i =0; i < matrix.size(); i++)
matrix[i][j]=0;}}//set the first row and first column zerosif(firstRowHasZero){for(int j =0; j < matrix[0].size();++j)
matrix[0][j]=0;}if(firstColumnHasZero){for(int i =0; i < matrix.size();++i)
matrix[i][0]=0;}return;}};