I have this code from this leetcode question:
function digArtifacts(n: number, artifacts: number[][], dig: number[][]): number {
const land: boolean[][] = new Array(n).fill(new Array(n).fill(false))
console.log(land)
dig.forEach(spot => {
console.log(spot, spot[0], spot[1])
land[spot[0]][spot[1]] = true
console.log(land)
})
console.log(land)
return 0
};
With this input
n = 2
artifacts = [[0,0,0,0],[0,1,1,1]]
dig = [[0,0],[0,1]]
With this stdout:
[ [ false, false ], [ false, false ] ]
[ 0, 0 ] 0 0
[ [ true, false ], [ true, false ] ] **but expected => [ [ true, false ], [ false, false ] ]
[ 0, 1 ] 0 1
[ [ true, true ], [ true, true ] ] **but expected [ [ true, true ], [ false, false ] ]
[ [ true, true ], [ true, true ] ] **but expected [ [ true, true ], [ false, false ] ]
Why do land[1][0]
=== true and land[1][1]
=== true when they are never accessed?