code for setMatrixZeros
add solution2 to improve the performance