Answered step by step
Verified Expert Solution
Link Copied!

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 1
How to Attempt?
Ataximum Pruits to Collect
Evan is planning to collect some fuits from a garden. The garden is described in a MN 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 1 : 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
input3 : An integer value X representing the starting row for Evan
inpurt4 : An integer value Y representing the starting column for Even.
input5 : An integer value K representing the number of steps Evan can take to collect the fiuits
input6 : A20 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 k steps.
Example 1:Output:8
Explanation:
Here the given size of the matrix is 34 Evan's starting position is inputc[3][3] and the number of allowed steps is 3. The matrix looks as follows:
2142
23
2201
initally Evan is standing at cell 83. W order to collect maximum number of fruts he can
first move to cel 23 and pick 2 frits:
then from cell 23 he can move to cell 1131 to get 4 more fruits.
inaly he can move to cell to get anothar 2 frits.
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
input3:1
Mettl Onlire Asmament C 2021-2031
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions