Question: JAVA Programming: The goal is to find the longest increasing path of a 2D matrix (m x n). We always start from the top left

JAVA Programming: The goal is to find the longest increasing path of a 2D matrix (m x n). We always start from the top left corner (matrix[0][0]) and end at the bottom right corner (matrix [m - 1][n - 1]). The movement can only be down or right, that's it (not up, left or diagonal). I need to print out the sum of the longest path taken and print the total number of possible paths if there are more than one. I assume this will need dynamic programming. Here is an example of some input:

Input : N = 4, M = 4 m[][] = { { 1, 2, 3, 4 }, { 2, 2, 3, 4 }, { 3, 2, 3, 4 }, { 4, 5, 6, 7 } };

The path in this case is: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 and there is only 1 solution so I need to print out:

Sum: 28

Number of paths: 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!