Skip to content

Instantly share code, notes, and snippets.

@Nublo
Created October 7, 2018 15:05
Show Gist options
  • Save Nublo/3f28f2579a0c7db4d8975937d74dcfc9 to your computer and use it in GitHub Desktop.
Save Nublo/3f28f2579a0c7db4d8975937d74dcfc9 to your computer and use it in GitHub Desktop.
public Integer maxSum(List<Integer> array) {
Integer max = array.get(0) + array.get(1);
for (int i = 2; i < array.size(); i++)
if (array.get(i) + array.get(i-1) > max)
max = array.get(i) + array.get(i-1);
return max;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment