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/0000-0099/0053.Maximum Subarray/README_EN.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,23 +64,23 @@ tags:
64
64
65
65
### Solution 1: Dynamic Programming
66
66
67
-
We define $f[i]$ to represent the maximum sum of the continuous subarray ending with the element $nums[i]$. Initially, $f[0] = nums[0]$. The final answer we are looking for is $\max_{0 \leq i < n} f[i]$.
67
+
We define $f[i]$ to represent the maximum sum of a contiguous subarray ending at element $\textit{nums}[i]$. Initially, $f[0] = \textit{nums}[0]$. The final answer we seek is $\max_{0 \leq i < n} f[i]$.
68
68
69
-
Consider $f[i]$, where $i \geq 1$, its state transition equation is:
69
+
Consider $f[i]$ for $i \geq 1$. Its state transition equation is:
Since $f[i]$ is only related to $f[i - 1],ドル we can use a single variable $f$ to maintain the current value of $f[i]$, and then perform state transition. The answer is $\max_{0 \leq i < n} f$.
81
+
Since $f[i]$ is only related to $f[i - 1],ドル we can use a single variable $f$ to maintain the current value of $f[i]$ and perform the state transition. The answer is $\max_{0 \leq i < n} f$.
82
82
83
-
The time complexity is $O(n),ドル where $n$ is the length of the array $nums$. We only need to traverse the array once to get the answer. The space complexity is $O(1)$, we only need constant space to store several variables.
83
+
The time complexity is $O(n),ドル where $n$ is the length of the array $\textit{nums}$. The space complexity is $O(1)$.
0 commit comments