Given a 2-D matrix M where each cell M[i][j] contains some number of coins, find a path to collect maximum coins from ce

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Given a 2-D matrix M where each cell M[i][j] contains some number of coins, find a path to collect maximum coins from ce

Post by answerhappygod »

Given A 2 D Matrix M Where Each Cell M I J Contains Some Number Of Coins Find A Path To Collect Maximum Coins From Ce 1
Given A 2 D Matrix M Where Each Cell M I J Contains Some Number Of Coins Find A Path To Collect Maximum Coins From Ce 1 (121.15 KiB) Viewed 20 times
Given a 2-D matrix M where each cell M[j] contains some number of coins, find a path to collect maximum coins from cell (x1, y1) to cell (x2, y2) in matrix M where x2 >= x1 and y2 >= y1. You can only travel one step right or one step down in each move. Write a function MaxCoinsPath(M,x1,y1,x1, y1) that accepts a matrix M, index (x1.y1) of the source cell and index (x2,y2) of the destination cell in matrix M. The function should return the maximum number of coins collected across all paths from source to destination. Sample Input 1 [[2.1.3.2.5].[3.5,2,4,6]. [7.6.1.3,2],[2.9.4,7,8],[1,4,5,11,3]] # Matrix M 2 (0,0) #Source (x1, y1) 3 (4,4) #Destination (x2.y2) Output 1 52 Explanation 2+3+7+6+9+4+7+11+3=52, which is maximum in all paths from (1,1) to (4,4).
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply