Back to course home
0% completed
Vote For New Content
Why does the bottom up solution here start with startIndex at n - 1 instead of 0...
Gary
May 13, 2022
Why does the bottom up solution here start with startIndex at n - 1 instead of 0, like in the Longest Common Substring/Subsequence problems in chapter 6?
1
0
Comments
Comments
G
George 3 years ago
Good question. You can go from 0 to n - 1 as well. The goal is to fill out the top right half of the 2D DP array. The method shown populates the top right half from left-to-right, bottom-to-top,
To do this from 0 to n - 1, the outer loop would represent the end indices...
On this page