Skip to content

Conversation

@hyanyul
Copy link
Collaborator

@hyanyul hyanyul commented Aug 20, 2025

⭐️ 문제에서 주로 사용한 알고리즘

  • 알고리즘 종류: DFS

📝 대략적인 코드 설명

    static void dfs(int x, int y) {
        visit[x][y] = true;    // 방문 표시
        houseCount++;
        
        for (int i=0; i<4; i++) {    // 상하좌우 이동
            int cx = x + dx[i];
            int cy = y + dy[i];
            
            if (cx >= 0 && cy >= 0 && cx < N && cy < N) {    // 지도 내의 좌표이고
                if (!visit[cx][cy] && map[cx][cy] == 1) {    // 방문한적 없으며, 집이 있을 때
                    dfs(cx, cy);    // 재귀호출을 통한 깊이 탐색
                }
            }
        }
    }

⏳ 시간 복잡도

O(N^2)

🪄 코드 리뷰시 요청사항

@hyanyul hyanyul self-assigned this Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant