File tree 1 file changed +8
-8
lines changed
scripts/algorithms/E/Equal Row and Column Pairs
1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change
1
+ // Runtime: 218 ms (Top 37.41%) | Memory: 52 MB (Top 63.08%)
1
2
var equalPairs = function ( grid ) {
2
3
let n = grid . length
3
4
let count = 0 ;
4
-
5
+
5
6
let map = new Map ( )
6
-
7
+
7
8
//making rowArray
8
9
for ( let row = 0 ; row < n ; row ++ ) {
9
10
let temp = [ ]
10
11
for ( let col = 0 ; col < n ; col ++ ) {
11
12
temp . push ( grid [ row ] [ col ] )
12
13
}
13
-
14
+
14
15
temp = temp . join ( )
15
16
16
17
if ( map . has ( temp ) ) {
@@ -21,20 +22,19 @@ var equalPairs = function(grid) {
21
22
map . set ( temp , 1 )
22
23
}
23
24
}
24
-
25
-
25
+
26
26
for ( let col = 0 ; col < n ; col ++ ) {
27
27
let temp = [ ]
28
28
for ( let row = 0 ; row < n ; row ++ ) {
29
29
temp . push ( grid [ row ] [ col ] )
30
30
}
31
-
31
+
32
32
temp = temp . join ( )
33
33
34
34
if ( map . has ( temp ) ) {
35
35
count += map . get ( temp )
36
36
}
37
37
}
38
-
38
+
39
39
return count ;
40
- } ;
40
+ } ;
You can’t perform that action at this time.
0 commit comments