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: solution/2900-2999/2943.Maximize Area of Square Hole in Grid/README_EN.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,15 +92,15 @@ tags:
92
92
93
93
### Solution 1: Sorting
94
94
95
-
The problem essentially asks us to find the length of the longest consecutive increasing subsequence in the array, and then add 1 to it.
95
+
The problem essentially asks us to find the length of the longest consecutive increasing subsequence in the array, and then add $1$.
96
96
97
-
We define a function $f(nums)$, which represents the length of the longest consecutive increasing subsequence in the array $nums$.
97
+
We define a function $f(\textit{nums})$ to represent the length of the longest consecutive increasing subsequence in the array $\textit{nums}$.
98
98
99
-
For the array $nums$, we first sort it, then traverse the array. If the current element $nums[i]$ equals the previous element $nums[i - 1]$ plus 1, it means that the current element can be added to the consecutive increasing subsequence. Otherwise, it means that the current element cannot be added to the consecutive increasing subsequence, and we need to start calculating the length of the consecutive increasing subsequence again. Finally, we return the length of the consecutive increasing subsequence plus 1.
99
+
For the array $\textit{nums}$, we first sort it, then iterate through the array. If the current element $\textit{nums}[i]$ equals the previous element $\textit{nums}[i - 1]$ plus $1$, it means the current element can be added to the consecutive increasing subsequence. Otherwise, the current element cannot be added to the consecutive increasing subsequence, and we need to restart counting the length of the consecutive increasing subsequence. Finally, we return the length of the consecutive increasing subsequence plus $1$.
100
100
101
-
After finding the length of the longest consecutive increasing subsequence in $hBars$ and $vBars$, we take the minimum of the two as the side length of the square, and then calculate the area of the square.
101
+
After finding the lengths of the longest consecutive increasing subsequences in $\textit{hBars}$ and $\textit{vBars}$, we take the minimum of the two as the side length of the square, and then calculate the area of the square.
102
102
103
-
The time complexity is $O(n \times \log n)$, and the space complexity is $O(n)$. Here, $n$ is the length of the array $hBars$ or $vBars$.
103
+
The time complexity is $O(n \times \log n)$, and the space complexity is $O(n)$, where $n$ is the length of the array $\textit{hBars}$ or $\textit{vBars}$.
0 commit comments