• + 0 comments

    You can also visualize this by thinking that a[p] denotes the starting point of an uprising in value and a[q+1] denotes the end point. In this case, traverse through the array is like climbing a mountain, and the sum we keep denotes the elevation.