You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,8 +85,6 @@ You can skip the more difficult problems and do them later.
85
85
-[188. Best Time to Buy and Sell Stock IV](en/1-1000/188-best-time-to-buy-and-sell-stock-iv.md) was solved in _Python, JavaScript, Go_.
86
86
-[309. Best Time to Buy and Sell Stock with Cooldown](en/1-1000/309-best-time-to-buy-and-sell-stock-with-cooldown.md) was solved in _Python, JavaScript, Go_.
87
87
88
-
to here now
89
-
90
88
## Subsequence Problems
91
89
-[674. Longest Continuous Increasing Subsequence](en/1-1000/674-longest-continuous-increasing-subsequence.md) was solved in _Python, Java, JavaScript, C#_.
92
90
-[300. Longest Increasing Subsequence](en/1-1000/300-longest-increasing-subsequence.md) was solved in _Python, Java, JavaScript, C#_.
Copy file name to clipboardExpand all lines: en/1-1000/827-making-a-large-island.md
+54-64Lines changed: 54 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,9 +60,9 @@ And this graph may have multiple **connected components** (islands):
60
60
## Approach
61
61
1. Change one vertex from `0` to `1` to make the largest island means combining the adjacent islands of a `0` vertex.
62
62
1. We can mark an island's lands with one same id (`island_id`), and mark another island's lands with another `island_id`. To mark a land, just change its value to the `island_id`.
63
-
1. Use a `map` (or an `array`) to map each `island_id` to its area (`land_count`).
63
+
1. Use a `map` (or an `array`) to map each `island_id` to its `area`.
64
64
1. How to calculate the area of an island? Using `Depth-First Search` or `Breadth-First Search`. See [695. Max Area of Island](695-max-area-of-island.md).
65
-
1. Iterate through each `0` (water), then sum the areas (`land_count`) of neighboring islands.
65
+
1. Iterate through each `0` (water), then sum the `areas` of neighboring islands.
66
66
1. Record the max area and return it.
67
67
68
68
## Complexity
@@ -71,88 +71,78 @@ And this graph may have multiple **connected components** (islands):
71
71
72
72
## Python
73
73
```python
74
+
from collections import defaultdict
75
+
74
76
classSolution:
75
77
def__init__(self):
76
-
self.result =0
77
-
self.grid =None
78
-
self.land_count =0
79
-
self.land_counts = [0, 0] # Since `island_id` starts from 2, the first two records will not be used
Copy file name to clipboardExpand all lines: zh/1-1000/827-making-a-large-island.md
+54-64Lines changed: 54 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,9 +60,9 @@ And this graph may have multiple **connected components** (islands):
60
60
## Approach
61
61
1. Change one vertex from `0` to `1` to make the largest island means combining the adjacent islands of a `0` vertex.
62
62
1. We can mark an island's lands with one same id (`island_id`), and mark another island's lands with another `island_id`. To mark a land, just change its value to the `island_id`.
63
-
1. Use a `map` (or an `array`) to map each `island_id` to its area (`land_count`).
63
+
1. Use a `map` (or an `array`) to map each `island_id` to its `area`.
64
64
1. How to calculate the area of an island? Using `Depth-First Search` or `Breadth-First Search`. See [695. Max Area of Island](695-max-area-of-island.md).
65
-
1. Iterate through each `0` (water), then sum the areas (`land_count`) of neighboring islands.
65
+
1. Iterate through each `0` (water), then sum the `areas` of neighboring islands.
66
66
1. Record the max area and return it.
67
67
68
68
## Complexity
@@ -71,88 +71,78 @@ And this graph may have multiple **connected components** (islands):
71
71
72
72
## Python
73
73
```python
74
+
from collections import defaultdict
75
+
74
76
classSolution:
75
77
def__init__(self):
76
-
self.result =0
77
-
self.grid =None
78
-
self.land_count =0
79
-
self.land_counts = [0, 0] # Since `island_id` starts from 2, the first two records will not be used
0 commit comments