# Building Bridges

Let's solve the Building Bridges problem using Dynamic Programming.

## Statement

Two cities are to be connected via `north`

and `south`

, consisting of positive integers.

Note:`north`

represents the coordinates of bridges on the northern bank of the river, whereas`south`

represents the coordinates of bridges on the southern bank.

What is the maximum number of bridges if the

For example, we have two arrays:

$north = [6, 4, 2, 1]$ $south = [2, 3, 6, 5]$

One possibility is that we can connect

**Constraints:**

$1 \leq n \leq 995$ $1 \leq$ `north.length`

$\leq n$ $1 \leq$ `south.length`

$\leq n$ $1 \leq$ `north[i]`

,`south[i]`

$\leq 10^5$

## Examples

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.