From 4acf688fb01dc2fe8bc8cebe8acc2bcfcbc2eb06 Mon Sep 17 00:00:00 2001 From: jungmyunggi Date: Thu, 2 Jan 2025 23:28:42 +0900 Subject: [PATCH] [Leetcode - Medium] Set Matrix Zeroes --- jungmyunggi/Set Matrix Zeroes.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 jungmyunggi/Set Matrix Zeroes.js diff --git a/jungmyunggi/Set Matrix Zeroes.js b/jungmyunggi/Set Matrix Zeroes.js new file mode 100644 index 0000000..6b59f9e --- /dev/null +++ b/jungmyunggi/Set Matrix Zeroes.js @@ -0,0 +1,28 @@ +/** + * @param {number[][]} matrix + * @return {void} Do not return anything, modify matrix in-place instead. + */ + +var setZeroes = function(matrix) { + if(matrix.length === 1 && matrix[0].includes(0)){ + matrix[0].fill(0); + return matrix + } + const arr = [] + for(let i=0;i