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 Input Specification:
input: An integer value representing the number of rows in the matrix.
input: An integer value representing the number of columns in the
matrix.
input: An integer value representing the starting row for Evan.
input: An integer value representing the starting column for Evan.
input: An integer value representing the number of steps Evan can take
to collect the fruits.
input: A 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 Output :
Explanation:
Here the given size of the matrix is Evan's starting position is input
and the number of allowed steps is The matrix looks as follows:
#includesstdio.h
#includerstring.h
Read only region start
int maxFruitsCollectedint inputint inputint inputint inputint inputint
Read only region end
Write code and remove the below exception.
Initially, Evan is standing at cell In order to collect maximum number of
fruits, he can
first move to cell and pick fruits,
throw "Function maxFruitsCollectedint input int input int input int input if
then from cell he can move to cell to get more fruits.
finally, he can move to cell to get another fruits.
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 :
Use Custom Input
input : Example :
input:
input :
input :
input :
input :
input :
Output :
Explanation:
Here the given size of the matrix is the starting position of Evan is
input and the number of allowed steps is The matrix looks as follows:
Evan is initially standing at cell In order to collect the maximum number of
fruits, he can
first move to cell and pick fruits, and
then, he can move from cell to cell to get another fruits.
Attempted:
KPp
Compiler:
#includesstdio.h
#includesstring.
Read only region start
int maxFruitsCollectedint input int inputint inputint inputint inputs, int
Read only region end
Write code and remove the below exception.
throw "Function maxFruitsCollectedint input int input int input int input it
Use Custom Inputinput:
input :
input :
input :
Output :
Explanation:
Here the given size of the matrix is the starting position of Evan is
input and the number of allowed steps is The matrix looks as follows:
Evan is initially standing at cell In order to collect the maximum number of
fruits, he can
first move to cell and pick fruits, and
then, he can move from cell to cell to get another fruits.
Thus he has taken steps
How to Attempt?
Maximum Fruits to Collect
Evan is planning to collect some fruits from a garden. The garden is described in
a matrix, where every element of the matriy epresents the number of
fruits in that cell.
Evan is initially in the row and column and can only take 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 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:
input: An integer value representing the number of rows in the matrix.
Attempted:
KPP
Compiler: g
#includesstdio.h
#inc
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
