var maxDistance = function (grid) {
let res = -1,
n = grid.length;
map = [[], []];
for (let i = 0; i < n; i++) {
for (let j = 0; j < n; j++) {
const p = grid[i][j];
console.log("p", p);
map[p].push([i, j]);
}
}
console.log("map", map);
console.log("map[0]", map[0]);
console.log("map[1]", map[1]);
};
const grid = [
[1, 0, 0],
[0, 0, 0],
[0, 0, 0],
];
console.log(maxDistance(grid));
const distance = (p0, p1) => {
const x0 = p0[0],
x1 = p1[0],
y0 = p0[0],
y1 = p0[1];
let d = 0;
if (x0 > x1) {
d += x0 - x1;
} else {
d += x1 - x0;
}
if (y0 > y1) {
d += y0 - y1;
} else {
d += y1 - y0;
}
console.log("d: ", d);
return d;
};