Skip to content

Instantly share code, notes, and snippets.

@harrylove
Created February 28, 2014 04:47
Show Gist options
  • Save harrylove/9265423 to your computer and use it in GitHub Desktop.
Save harrylove/9265423 to your computer and use it in GitHub Desktop.
max, vol, memo = 0, 0, 0
[2, 5, 1, 3, 1, 2, 1, 7, 7, 6].each do |n|
if n > max
max = n
vol += memo
memo = 0
else
memo += max - n
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment