Fix index variable
This commit is contained in:
commit
5a927cc4a0
|
@ -457,8 +457,8 @@ After this change, the time complexity is $O(n^2)$.
|
||||||
|
|
||||||
Surprisingly, it is possible to solve the problem
|
Surprisingly, it is possible to solve the problem
|
||||||
in $O(n)$ time\footnote{In \cite{ben86}, this linear-time algorithm
|
in $O(n)$ time\footnote{In \cite{ben86}, this linear-time algorithm
|
||||||
is attributed to J. B. Kadene, and the algorithm is sometimes
|
is attributed to J. B. Kadane, and the algorithm is sometimes
|
||||||
called \index{Kadene's algorithm} \key{Kadene's algorithm}.}, which means
|
called \index{Kadane's algorithm} \key{Kadane's algorithm}.}, which means
|
||||||
that just one loop is enough.
|
that just one loop is enough.
|
||||||
The idea is to calculate, for each array position,
|
The idea is to calculate, for each array position,
|
||||||
the maximum sum of a subarray that ends at that position.
|
the maximum sum of a subarray that ends at that position.
|
||||||
|
|
|
@ -28,6 +28,6 @@ You can always send feedback on the book to
|
||||||
\texttt{ahslaaks@cs.helsinki.fi}.
|
\texttt{ahslaaks@cs.helsinki.fi}.
|
||||||
|
|
||||||
\begin{flushright}
|
\begin{flushright}
|
||||||
Helsinki, June 2017 \\
|
Helsinki, July 2017 \\
|
||||||
Antti Laaksonen
|
Antti Laaksonen
|
||||||
\end{flushright}
|
\end{flushright}
|
||||||
|
|
Loading…
Reference in New Issue