Skip to content

Instantly share code, notes, and snippets.

@shaobin0604
Created June 15, 2012 02:02
Show Gist options
  • Select an option

  • Save shaobin0604/2934272 to your computer and use it in GitHub Desktop.

Select an option

Save shaobin0604/2934272 to your computer and use it in GitHub Desktop.
满分答案
// you can also use imports, for example:
// import java.math.*;
class Solution {
int equi(int[] a) {
final int b = a.length;
long left = 0;
long right = 0;
for (int i = 0; i < b; i++) {
right += a[i];
}
for (int i = 0; i < b; i++) {
right -= a[i];
if (left == right) {
return i;
}
left += a[i];
}
return -1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment