Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b66aeb9

Browse files
committed
73/81 problem
1 parent 174f6a7 commit b66aeb9

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

‎71-80/73. Set Matrix Zeroes.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var setZeroes = function(matrix) {
2+
let [r,c] = [new Set(),new Set()]
3+
let [col,row] = [matrix[0].length,matrix.length]
4+
for(let i = 0 ; i < row; i++){
5+
for(let j = 0 ; j < col; j++){
6+
if(matrix[i][j] == 0){
7+
r.add(i);c.add(j)
8+
}
9+
}
10+
}
11+
let rz = (n) =>{
12+
for(let i = 0; i < col; i++){matrix[n][i] = 0}
13+
}
14+
let cz = (n) =>{
15+
for(let i = 0; i < row; i++){matrix[i][n] = 0}
16+
}
17+
r = Array.from(r.values())
18+
c = Array.from(c.values())
19+
for(let i = 0; i < r.length; i++){rz(r[i])}
20+
for(let i = 0; i < c.length; i++){cz(c[i])}
21+
return matrix
22+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
var search = function(nums, target) {
2+
// Set.has() returns true if value is in the set
3+
return new Set(nums).has(target)
4+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /