You are viewing a single comment's thread. Return to all 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.
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.
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.
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Array Manipulation
You are viewing a single comment's thread. Return to all 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.
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:
The maximum value of the accumulated sum is 200.
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.