function solution(arr) {
var answer = [0,0];
let z=arr.length;
const check=(x, y, length)=>{
let theNumber=arr[x][y];
let half=Math.floor(length/2);
for (let i=x;i<x+length;i++){
for (let j=y;j<y+length;j++){
if (arr[i][j]!==theNumber){
check(x, y, half);
check(x+half, y, half);
check(x, y+half, half);
check(x+half, y+half, half);
return;
}
}
}
answer[theNumber]+=1;
}
check(0, 0, z)
return answer;
}
https://eunchanee.tistory.com/668