Consider a non-empty array of integers inarr containing positive values inclusive of zero. The elements of inarr are positioned in sequence le 1st element at 1 position, 2nd element at 2 position and so on. Identify and print outarr containing two Integer values based on the logic given below: . Starting from the first(leftmost) position in inarr, reach the last position such that: from current position currentpos having a value val, move to a position, nextpos, in the right where the nextpos is not more than val positions away from currentpos A move is defined as change in position Le. from currentpos to nextpos • Identify the path that has the minimum number of moves made to reach the last position and the sum of the values at each position in the path, including the values at the first and the last position Store the sum of values identified as the first element of outarr and the minimum number of moves as the second element of outarr Print-1 if you cannot reach the last position of inarr All paths with minimum number of moves that reach the last position of inarr would have the same sum Input format Read the input inarr with the elements separated by, (comma) from the standard input stream Output format
Answers
Answered by
0
Answer:
PLEASE MARK ME AS BRAINLEAST PLEASE MARK ME AS BRAINLEAST PLEASE PLEASE ME AS BRAINLEAST❤
Similar questions