Closed
Description
Bug Report for https://neetcode.io/problems/valid-sudoku
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
Running this code:
class Solution {
/**
* @param {character[][]} board
* @return {boolean}
*/
isValidSudoku(board) {
// create 9 + 9 + 9 lists
const lists = []
const boxes = []
for(let i = 0; i < 9; i++) {
const row = board[i]
lists.push(row)
const col = []
// 9 boxes, 0,0, 0,1, 0,2 -- think of it as a 3x3 matrix
for(let j = 0; i < 9; j++) { // technically a double for loop but capped at 9x9 operations
col.push(board[i][j])
console.log('test')
let boxI = Math.floor(i / 3)
if (boxI == 3) boxI = 2
let boxJ = Math.floor(j / 3)
if(boxJ == 3) boxJ = 2
const boxesIndex = boxI * 3 + boxJ
if(boxesIndex in boxes) {
boxes[boxesIndex].push(board[i][j])
} else {
boxes[boxesIndex] = [board[i][j]]
}
}
lists.push(col)
}
lists.push(...boxes)
// console.log(lists)
return true
// for each list, create a set and itereate through to ensure no duplicates
}
}
Getting this error:

Metadata
Metadata
Assignees
Labels
No labels