File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -101,22 +101,22 @@ const candyCrush = function (board) {
101
101
if ( val === 0 ) continue
102
102
if (
103
103
j < M - 2 &&
104
- Math . abs ( board [ i ] [ j + 1 ] ) == val &&
105
- Math . abs ( board [ i ] [ j + 2 ] ) == val
104
+ Math . abs ( board [ i ] [ j + 1 ] ) === val &&
105
+ Math . abs ( board [ i ] [ j + 2 ] ) === val
106
106
) {
107
107
found = true
108
108
let ind = j
109
- while ( ind < M && Math . abs ( board [ i ] [ ind ] ) == val )
109
+ while ( ind < Math . min ( M , j + 3 ) && Math . abs ( board [ i ] [ ind ] ) = == val )
110
110
board [ i ] [ ind ++ ] = - val
111
111
}
112
112
if (
113
113
i < N - 2 &&
114
- Math . abs ( board [ i + 1 ] [ j ] ) == val &&
115
- Math . abs ( board [ i + 2 ] [ j ] ) == val
114
+ Math . abs ( board [ i + 1 ] [ j ] ) === val &&
115
+ Math . abs ( board [ i + 2 ] [ j ] ) === val
116
116
) {
117
117
found = true
118
118
let ind = i
119
- while ( ind < N && Math . abs ( board [ ind ] [ j ] ) == val )
119
+ while ( ind < Math . min ( N , i + 3 ) && Math . abs ( board [ ind ] [ j ] ) = == val )
120
120
board [ ind ++ ] [ j ] = - val
121
121
}
122
122
}
You can’t perform that action at this time.
0 commit comments