Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lv.2] 쿼드압축 후 개수 세기 #176

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
최종 코드
  • Loading branch information
say-young516 committed May 30, 2023
commit 96d59d7b8e51961123b977a40980af648eb28f7a
21 changes: 21 additions & 0 deletions programmers/Lv.2/쿼드압축 후 개수 세기/main.js
Original file line number Diff line number Diff line change
@@ -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;
}