Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<math.h>
- int solution(vector<int> &A) {
- // write your code in C++14 (g++ 6.2.0)
- int size = (int)A.size();
- int cnt = 0, res = 0;
- for (int i = 0; i < size; i++) {
- if (A[i] == 0) {
- cnt++;
- } else {
- res += cnt;
- }
- }
- if (abs(res) > 1000000000) {
- return -1;
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement