Question: Question 1 Input Specification: input 1 : An integer value M representing the number of rows in the matrix. input 2 : An integer value

Question 1 Input Specification:
input1: An integer value M representing the number of rows in the matrix.
input2: An integer value N representing the number of columns in the
matrix.
input3: An integer value x representing the starting row for Evan.
input4: An integer value Y representing the starting column for Evan.
input5: An integer value K representing the number of steps Evan can take
to collect the fruits.
input6: A 2D integer array, of size MxN, wher integer represts the
number of fruits in that cell.
Output Specification:
Return an integer value representing the maximum number of fruits Evan
can collect in K steps.
#includesstdio.h>
#include(|2,1,4,2),(3,1,2,3),(2,2,0,1) Output : 8
Explanation:
Here the given size of the matrix is 34, Evan's starting position is input6[3][3]
and the number of allowed steps is 3. The matrix looks as follows:
2142
3123
2201
#includesstdio.h>
#includerstring.h>
// Read only region start
int maxFruitsCollected(int input1,int input2,int input3,int input4,int input5,int **
{
// Read only region end
// Write code and remove the below exception.
Initially, Evan is standing at cell {3,3}. In order to collect maximum number of
fruits, he can
first move to cell {2,3} and pick 2 fruits,
throw "Function maxFruitsCollected(int input1, int input2, int input3, int input4, if
then from cell {2,3}, he can move to cell {1,3} to get 4 more fruits.
finally, he can move to cell (1,4) to get another 2 fruits.
He would thus have taken 3 steps and therefore cannot move further. Since the
total number of fruits he picked is 8,8 is returned as the output.
Example 2:
input1:3
input2 : 3
Use Custom Input
input3 : 1 Example 2:
input1:3
input2 : 3
input3 : 1
input 4: 1
input5 : 2
input6 : {(0,5,2),{5,3,60},(6,50,70}}
Output : 11
Explanation:
Here the given size of the matrix is 33, the starting position of Evan is
input6[1][1] and the number of allowed steps is 2. The matrix looks as follows:
052
5360
65070
Evan is initially standing at cell (1,1). In order to collect the maximum number of
fruits, he can
first move to cell {2,1} and pick 5 fruits, and
then, he can move from cell (2,1) to cell (3,1) to get another 6 fruits.
Attempted: 0/1
KPp
Compiler: g++5.4.0
#includesstdio.h>
#includesstring. h>
// Read only region start
int maxFruitsCollected(int input1, int input2,int input3,int input4,int inputs, int m??&.
{
// Read only region end
// Write code and remove the below exception.
throw "Function maxFruitsCollected(int input1, int input2, int input3, int input4, it
Use Custom Inputinput3: 1
input 4: 1
input5 : 2
input6 : {{0,5,2},{5,3,60},{6,50,70}}
Output : 11
Explanation:
Here the given size of the matrix is 33, the starting position of Evan is
input6[1][1] and the number of allowed steps is 2. The matrix looks as follows:
052
5360
65070
Evan is initially standing at cell (1,1). In order to collect the maximum number of
fruits, he can
first move to cell {2,1} and pick 5 fruits, and
then, he can move from cell {2,1} to cell (3,1) to get another 6 fruits.
Thus he has taken 2 steps
How to Attempt?
Maximum Fruits to Collect
Evan is planning to collect some fruits from a garden. The garden is described in
a MN matrix, where every element of the matriy epresents the number of
fruits in that cell.
Evan is initially in the xth row and Yth column and can only take K steps to
collect the fruits. In every step, he can move to any one of the four adjacent
cells and can collect the fruit present in that cell.
Your task is to find and return an integer value representing the maximum
number of fruits that Evan can collect in K steps.
Note:
Each cell can be visited only ance.
The storting position of fivan will alvogs have of fruits.
The matrix has one based indering
Input Specification:
input1: An integer value M representing the number of rows in the matrix.
Attempted:0/1
KPP
Compiler: g++5.4.0
#includesstdio.h>
#inc

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 Programming Questions!