Created
June 15, 2012 02:02
-
-
Save shaobin0604/2934272 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
| // 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