Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created November 10, 2010 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amalloy/e8c514dd7543d071fbf2 to your computer and use it in GitHub Desktop.
Save amalloy/e8c514dd7543d071fbf2 to your computer and use it in GitHub Desktop.
public static int[] intermediateSums(int[] array) {
int[] res = array.clone();
int sum = 0;
for (int i = 0; i < res.length; i++) {
sum+= array[i];
res[i] = sum;
}
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment