Number of Paths(Java Solution)

A Question on Pramp platform

There are three ways that you can solve it.

  1. Memoization + recursive function

2. bottom-up dynamic programming( SC: O(n²) )

The solution below uses bottom-up dynamic programming algorithm to solve it. The time complexity here is O(n²) and the space complexity here is O(n²).

3. bottom-up dynamic programming( SC: O(n) )

The solution below is a bit optimized it by minimizing the space complexity into O(n).

--

--

“If you can dream it, you can do it.”

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store