From 96d59d7b8e51961123b977a40980af648eb28f7a Mon Sep 17 00:00:00 2001 From: seyoung choi Date: Tue, 30 May 2023 23:01:10 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=EC=BD=94=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main.js" | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 "programmers/Lv.2/\354\277\274\353\223\234\354\225\225\354\266\225 \355\233\204 \352\260\234\354\210\230 \354\204\270\352\270\260/main.js" diff --git "a/programmers/Lv.2/\354\277\274\353\223\234\354\225\225\354\266\225 \355\233\204 \352\260\234\354\210\230 \354\204\270\352\270\260/main.js" "b/programmers/Lv.2/\354\277\274\353\223\234\354\225\225\354\266\225 \355\233\204 \352\260\234\354\210\230 \354\204\270\352\270\260/main.js" new file mode 100644 index 0000000..6625633 --- /dev/null +++ "b/programmers/Lv.2/\354\277\274\353\223\234\354\225\225\354\266\225 \355\233\204 \352\260\234\354\210\230 \354\204\270\352\270\260/main.js" @@ -0,0 +1,21 @@ +function solution(arr) { + const answer = [0, 0]; + function recur(x, y, length) { + let val = arr[y][x]; + for (let i = y; i < y + length; i++) { + for (let j = x; j < x + length; j++) { + if (arr[i][j] !== val) { + recur(x, y, length / 2); + recur(x + length / 2, y, length / 2); + recur(x, y + length / 2, length / 2); + recur(x + length / 2, y + length / 2, length / 2); + return; + } + } + } + + answer[val] += 1; + } + recur(0, 0, arr.length); + return answer; +}