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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started