Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Coding Question # Revisit Later Question 1 How to Attempt? Ataximum Pruits to Collect Evan is planning to collect some fuits from a garden. The
Coding Question #
Revisit Later
Question
How to Attempt?
Ataximum Pruits to Collect
Evan is planning to collect some fuits from a garden. The garden is described in a matrix where every element of the matrix represents the number of fruits in that cell. In that cell.
Your task is to find and retum an integer value representing the maximum number of fruits that Evan can collect in K steps.
Note:
Exchacell man bc visiter briy ance
The strrting position of Evam wat alietrys htre of fruis
The motrik hos ane besed itdering
Input Specification:
inpurt : An integer value M representing the number of rows in the matric
inpurz : An integer value N representing the number of columns in the matrix
input : An integer value X representing the starting row for Evan
inpurt : An integer value Y representing the starting column for Even.
input : An integer value K representing the number of steps Evan can take to collect the fiuits
input : integer array of size Miv where each integer represents the number of rruits in that call
Output Specification:
Geturn an integer value representing the maumum number of fruits Evan can oollect in steps.
Example :Output:
Explanation:
Here the given size of the matrix is Evan's starting position is inputc and the number of allowed steps is The matrix looks as follows:
initally Evan is standing at cell W order to collect maximum number of fruts he can
first move to cel and pick frits:
then from cell he can move to cell to get more fruits.
inaly he can move to cell to get anothar frits.
He would thus have taken steps and therefore cannot move further. Since the total number of fruits he picked is is returned as the output:
Example
input
input :
input:
Mettl Onlire Asmament C
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