
There will be an input of an array of given length which consists of numbers >0 which denote the number of goods .the number of goods denotes the profit that can be generated by selling each item for example if the array consists [3,5] this means profits we can obtain by selling these 8 items will be 1,2,3, and 1,2,3,4,5 then the maximum profit we can generate by selling any 4 items will be 5+4+3+3 = 15. we need output the maximum profit that can generated by selling given number of goods.
Sample test case :
Input:
3 (array size)
[2,6,4]
5 (number of goods we need to sell to obtain profit)
output:
22 (6+5+4+4+3) (max profit by selling 5 goods) 
There is an array which is filled with numbers > 0 .we need to find path to last element of the array where each element can travel only to two positions which can be obtained as i + arr[i] and i  arr[i](only if this equals >0) .By using this method if we can move to the last element in the array then we need to print the score of each element which is the number of elements visited by the current element else print 1.
Sample Test Case:
Input:
4 (array size)
2
4
1
2
output:
2 (from first position we can travel to 3 (2+1) and from 3 we can travel to 4(3+1))
1 (only possible moves are 4+2 and 42 so it cant move further)
1 ( from this position we can reach 1+3 = 4 th position)
0 (itself need not to travel further)
If there are any similar questions of this type please share them with me
Thank You