Created
October 30, 2013 18:48
-
-
Save resure/7237896 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var count = function (data) { | |
var left = 0, | |
right = data.length - 1, | |
result = 0; | |
for (i = left + 1; i < right; i++) { | |
if (data[i] < data[left]) | |
result += data[left] - data[i]; | |
else | |
left = i; | |
} | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment