TEST CASE
i/p-> n=5,k=3
arr= 9,1,5,4,1
o/p->45
explanation: first element chosen is rightmost 1, then all rest of the elements are doubled
sum+=1;
new array=18,2,10,8
then select second element rightmost 8 in new array, then all rest of the elements are doubled
sum+=8
new array=36,4,20
now leftmost element 36
sum+=36
so sum=45
there is a clearly visible pattern in this one, but why did you choose the left most element at the end of the processing your array and how do you determine when to choose the left-most?
aklil
Never Spam Bot
Zidane
Manav