Skip to content

Commit e493a4b

Browse files
committed
feat(leetcode): solve 200 - Number Of Islands
1 parent 876ee71 commit e493a4b

5 files changed

Lines changed: 60 additions & 18 deletions

File tree

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ Total 122
2222
2323
| Field | Value |
2424
|------|------|
25-
| Problem ID | 133 |
26-
| Title | Clone Graph |
25+
| Problem ID | 200 |
26+
| Title | Number Of Islands |
2727
| Language | Python3 |
28-
| Runtime | 49 ms |
29-
| Memory | 19.8 MB |
28+
| Runtime | 252 ms |
29+
| Memory | 21.6 MB |
3030
3131
3232
💻 Languages Used
3333
34-
- **Python3** : 5
34+
- **Python3** : 6
3535
3636
## 📚 Recent Accepted Problems
3737
38+
- 200 Number Of Islands
3839
- 133 Clone Graph
3940
- 1 Two Sum
4041
- 295 Find Median From Data Stream
4142
- 1 Two Sum
42-
- 295 Find Median From Data Stream
4343
4444
4545
---
@@ -81,4 +81,4 @@ Git
8181
GitHub
8282
⏰ Last Sync
8383
84-
2026-07-03 14:03:05
84+
2026-07-03 14:03:07
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"submission_id": "2053688232",
3+
"question_id": "200",
4+
"title_slug": "number-of-islands",
5+
"language": "python3",
6+
"language_verbose": "Python3",
7+
"runtime": "252 ms",
8+
"memory": "21.6 MB",
9+
"status_code": 10,
10+
"timestamp": 1783006494
11+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
class Solution:
2+
def numIslands(self, grid: List[List[str]]) -> int:
3+
rows = len(grid)
4+
cols = len(grid[0])
5+
6+
islands = 0
7+
8+
def dfs(r, c):
9+
if (
10+
r < 0 or
11+
c < 0 or
12+
r >= rows or
13+
c >= cols or
14+
grid[r][c] == "0"
15+
):
16+
return
17+
grid[r][c]= "0"
18+
19+
dfs(r + 1, c)
20+
dfs(r - 1, c)
21+
dfs(r, c + 1)
22+
dfs(r, c - 1)
23+
24+
for r in range(rows):
25+
for c in range(cols):
26+
27+
if grid[r][c]== "1":
28+
islands +=1
29+
30+
dfs(r,c)
31+
return islands

storage/state.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"last_submission_id": "2052380776"
2+
"last_submission_id": "2054682645"
33
}

storage/stats.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
"medium": 53,
55
"hard": 6,
66
"languages": {
7-
"Python3": 5
7+
"Python3": 6
88
},
99
"recent_problems": [
10+
{
11+
"id": "200",
12+
"title": "Number Of Islands"
13+
},
1014
{
1115
"id": "133",
1216
"title": "Clone Graph"
@@ -22,18 +26,14 @@
2226
{
2327
"id": "1",
2428
"title": "Two Sum"
25-
},
26-
{
27-
"id": "295",
28-
"title": "Find Median From Data Stream"
2929
}
3030
],
3131
"last_problem": {
32-
"id": "133",
33-
"title": "Clone Graph",
32+
"id": "200",
33+
"title": "Number Of Islands",
3434
"language": "Python3",
35-
"runtime": "49 ms",
36-
"memory": "19.8 MB"
35+
"runtime": "252 ms",
36+
"memory": "21.6 MB"
3737
},
38-
"last_sync": "2026-07-03 14:03:05"
38+
"last_sync": "2026-07-03 14:03:07"
3939
}

0 commit comments

Comments
 (0)