• + 2 comments

    @julie_larson
    100+100+100-100-100 = 100 still not 200 I've been banging my head still not able to understand this solution.

    • + 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.

    • + 0 comments

      They're always checking the sum against the count, so when the sum is less than the count (which is the greatest sum so far) the count doesn't update.