largestFiniteArea = {
let unboundedCentroids = new Set();
let centroidAreas = {}
for (let x = minX; x <= maxX; x++) {
for (let y = minY; y <= maxY; y++) {
const distances = centroids.map(c => [manhattanDistance(c, [x, y]), c]).sort((a, b) => a[0] - b[0]);
if (distances[0][0] !== distances[1][0]) {
centroidAreas[distances[0][1]] = (centroidAreas[distances[0][1]] || 0) + 1;
}
if (x === minX || y === minY || x === maxX || y === maxY) {
unboundedCentroids.add(distances[0][1]);
}
}
}
for (const centroid of unboundedCentroids) {
delete centroidAreas[centroid];
}
return Math.max(...Object.entries(centroidAreas).map(e => e[1]));
}