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 directions of the longest path taken. I assume this will need dynamic programming (maybe bottom to top). Here is an example of some input:

Input : M = 6, N = 4 m[][] = { { 1, 1, 2, 3 }, { 1, 5, 6, 7 }, { 2, 5, 10, 11 }, { 3, 7, 11, 15}, {20, 20, 20, 1}, {20, 20, 20, 1}}; The path ends up being 1->1->2->3->20->20->20->20->1

So I need to print out:

DOWN DOWN DOWN DOWN DOWN RIGHT RIGHT RIGHT

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!