Created
January 29, 2018 08:37
-
-
Save clarkdo/0e4616952a754218cd28b6fc95daf569 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
class Solution { | |
public int solution(int[] A) { | |
int pairs = 0; | |
int easts = 0; | |
for (int i : A) { | |
if (i == 0) { | |
easts++; | |
} else { | |
pairs += easts; | |
} | |
if (pairs > 1e9) { | |
pairs = -1; | |
break; | |
} | |
} | |
return pairs; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment