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: content/6_Advanced/Lagrange.mdx
+1-1
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ The problem gives us a length $N$ ($1 \le N \le 3 \cdot 10^5$) array of integers
35
35
36
36
The main bottleneck of any dynamic programming solution to this problem is having to store the number of subarrays we have created so far.
37
37
38
-
Let's try to find a way around this. Instead of storing the number of subarrays we have created so far, we assign a penalty of $\lambda$ for creating a new subarray (i.e. everytime we create a subarray we penalize our sum by $\lambda$).
38
+
Let's try to find a way around this. Instead of storing the number of subarrays we have created so far, we assign a penalty of $\lambda$ for creating a new subarray (i.e. every time we create a subarray we penalize our sum by $\lambda$).
39
39
40
40
This leads us to the sub-problem of finding the maximal sum and number of subarrays used if creating a new subarray costs $\lambda$. We can solve this in $\mathcal{O}(N)$ time with dynamic programming.
0 commit comments