Building Bridges
Explore how to find the maximum number of non-overlapping bridges between two cities using dynamic programming. Understand the naive recursive solution and then optimize it with top-down and bottom-up approaches based on the longest common substring pattern. Gain skills in solving recursive problems efficiently by applying memoization and tabulation methods to reduce time complexity and improve performance.
Statement
Two cities are to be connected via north and south, consisting of positive integers.
Note:
northrepresents the coordinates of bridges on the northern bank of the river, whereassouthrepresents the coordinates of bridges on the southern bank.
What is the maximum number of bridges if the
For example, we have two arrays:
One possibility is that we can connect