We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fc50dd4 commit 76f5c08Copy full SHA for 76f5c08
src/flood_fill.py
@@ -3,13 +3,8 @@
3
4
https://leetcode.com/problems/flood-fill
5
6
-Example:
7
-
8
- j →
9
- i
10
- ↓ 1 1 1 2 2 2
11
- 1 1 0 → 2 2 0
12
- 1 0 1 2 0 1
+NOTES
+ * Use breadth-first search.
13
14
This problem is very straight-forward if you use breadth-first search. Simply
15
add adjacent pixels that share the same color as the starting pixel to the
@@ -45,6 +40,14 @@
45
40
46
41
This solution has O(n) time complexity and O(n) space complexity, since, in the
47
42
worst case, we will need to visit every pixel in the image.
43
+
44
+Example:
+ j →
+ i
48
+ ↓ 1 1 1 2 2 2
49
+ 1 1 0 → 2 2 0
50
+ 1 0 1 2 0 1
51
"""
52
53
from collections import deque
0 commit comments