main / east-west-pairs
Write a function solve(array) that will count the number of pairs of cars, one going East (0) and another later going West (1). Given an array: [0, 1, 0, 1, 1] it should count the pairs: for the car at (1): (1, 2), (1, 4), (1, 5); and then for the car at (3): (3, 4), (3, 5). The result should be 5. Note: if the result is higher than 1,000,000,000 the function should return -1
Test pairs (public)
solve([0,1,0,1,1]) = 5
Only one (private)
solve(?) = ?
Big array ~100,000 elements, all 0s (private)
solve(?) = ?
Big array ~100,000 elements, all 1s (private)
solve(?) = ?
Big array ~100,000 elements, random (private)
solve(?) = ?
Verification time:
Code size: