• + 0 comments

    The final diff array should be like this:

    100 100 0 0 -100 (straight foward from the code)

    So when you iterate over it to get the accumalated sum you'll get this:

    iteration		value of x	accumulated sum
    0			0		0
    1			100		100
    2			100		200	
    3			0		200
    4			0		200
    5			-100		100
    

    The maximum value of the accumulated sum is 200.