boj 11725 트리의 부모 찾기
https://www.acmicpc.net/problem/11725
그래프를 인접리스트로 저장한다.
bfs를 진행하면서 parent배열(정점의 부모를 나타냄) 이 없고 a->b로 가는 간선이 있으면
parent[b]=a를 진행한다.
bfs를 부모노드를 찾는 곳에 쓰이리라고는 생각도 못했다.
leetcode 섬의 개수
Number of Islands - LeetCode
Can you solve this real interview question? Number of Islands - Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent l
leetcode.com
bfs, dfs로 육지로 이루어진(1로 이루어짐) 섬의 개수를 세야한다.
bfs, dfs로 Flood Fill( 다차원 배열에서 연결된 영역을 찾는 알고리즘) 이 가능하다.
'Jungle > Everyday' 카테고리의 다른 글
| 3/30 파이썬 비동기 프로그래밍 (0) | 2026.03.31 |
|---|---|
| 3/27 DP(Dynamic Programming) (0) | 2026.03.28 |
| 3/18 (0) | 2026.03.19 |
| 3/17 (0) | 2026.03.18 |
| 3/16 (0) | 2026.03.17 |