• + 0 comments

    well the process goes like this, the question is to add the values to the array in between 2 indexes, instead what we do is, at the start index, we add the number and after the end index we subtract the number. and finally we loop it to make the sum of all elements in the array, we find the maximum sum possible. and the logic is, here key is to find the maximum sum, but not generating the array, so when we add a number at start index, all the consecutive sums have the number in it's sum and when we subtract it we are actually removing the number so it does not exists outside the end index. by looping and finding the sum gives the maximum number. Hope my explination helped...