File tree Expand file tree Collapse file tree
solutions/0130_Surrounded_Regions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,33 +9,33 @@ Automatically synchronize accepted LeetCode submissions to GitHub.
99``` text
1010████████████░░░░░░░░░░░░░░░░░░
1111
12- Solved: 127 / 300 Problems
12+ Solved: 128 / 300 Problems
1313
1414📊 Statistics
1515Difficulty Solved
1616🟢 Easy 63
17- 🟡 Medium 58
17+ 🟡 Medium 59
1818🔴 Hard 6
19- Total 127
19+ Total 128
2020🔥 Latest Accepted Problem
2121
2222
2323| Field | Value |
2424|------|------|
25- | Problem ID | 4136 |
26- | Title | Concatenate Non Zero Digits And Multiply By Sum Ii |
25+ | Problem ID | 130 |
26+ | Title | Surrounded Regions |
2727| Language | Python3 |
28- | Runtime | 361 ms |
29- | Memory | 57.8 MB |
28+ | Runtime | 8 ms |
29+ | Memory | 22.3 MB |
3030
3131
3232💻 Languages Used
3333
34- - **Python3** : 86
34+ - **Python3** : 87
3535
3636## 📚 Recent Accepted Problems
3737
38- - 4136 Concatenate Non Zero Digits And Multiply By Sum Ii
38+ - 130 Surrounded Regions
3939- 4136 Concatenate Non Zero Digits And Multiply By Sum Ii
4040- 4136 Concatenate Non Zero Digits And Multiply By Sum Ii
4141- 4136 Concatenate Non Zero Digits And Multiply By Sum Ii
8181GitHub
8282⏰ Last Sync
8383
84- 2026-07-10 14:25:27
84+ 2026-07-10 19:26:33
Original file line number Diff line number Diff line change 1+ {
2+ "submission_id" : " 2062990749" ,
3+ "question_id" : " 130" ,
4+ "title_slug" : " surrounded-regions" ,
5+ "language" : " python3" ,
6+ "language_verbose" : " Python3" ,
7+ "runtime" : " 8 ms" ,
8+ "memory" : " 22.3 MB" ,
9+ "status_code" : 10 ,
10+ "timestamp" : 1783696237
11+ }
Original file line number Diff line number Diff line change 1+ class Solution :
2+ def solve (self , board : List [List [str ]]) -> None :
3+ """
4+ Do not return anything, modify board in-place instead.
5+ """
6+
7+ rows = len (board )
8+ cols = len (board [0 ])
9+
10+ def dfs (r , c ):
11+
12+ if (
13+ r < 0 or
14+ c < 0 or
15+ r >= rows or
16+ c >= cols or
17+ board [r ][c ] != "O"
18+ ):
19+ return
20+
21+ board [r ][c ] = "T"
22+
23+ dfs (r + 1 , c )
24+ dfs (r - 1 , c )
25+ dfs (r , c + 1 )
26+ dfs (r , c - 1 )
27+
28+ # Left & Right borders
29+ for r in range (rows ):
30+
31+ dfs (r , 0 )
32+ dfs (r , cols - 1 )
33+
34+ # Top & Bottom borders
35+ for c in range (cols ):
36+
37+ dfs (0 , c )
38+ dfs (rows - 1 , c )
39+
40+ # Flip / Restore
41+ for r in range (rows ):
42+ for c in range (cols ):
43+
44+ if board [r ][c ] == "O" :
45+ board [r ][c ] = "X"
46+
47+ elif board [r ][c ] == "T" :
48+ board [r ][c ] = "O"
Original file line number Diff line number Diff line change 11{
2- "total" : 127 ,
2+ "total" : 128 ,
33 "easy" : 63 ,
4- "medium" : 58 ,
4+ "medium" : 59 ,
55 "hard" : 6 ,
66 "languages" : {
7- "Python3" : 86
7+ "Python3" : 87
88 },
99 "recent_problems" : [
1010 {
11- "id" : " 4136 " ,
12- "title" : " Concatenate Non Zero Digits And Multiply By Sum Ii "
11+ "id" : " 130 " ,
12+ "title" : " Surrounded Regions "
1313 },
1414 {
1515 "id" : " 4136" ,
2929 }
3030 ],
3131 "last_problem" : {
32- "id" : " 4136 " ,
33- "title" : " Concatenate Non Zero Digits And Multiply By Sum Ii " ,
32+ "id" : " 130 " ,
33+ "title" : " Surrounded Regions " ,
3434 "language" : " Python3" ,
35- "runtime" : " 361 ms" ,
36- "memory" : " 57.8 MB"
35+ "runtime" : " 8 ms" ,
36+ "memory" : " 22.3 MB"
3737 },
38- "last_sync" : " 2026-07-10 14:25:27 "
38+ "last_sync" : " 2026-07-10 19:26:33 "
3939}
You can’t perform that action at this time.
0 commit comments