Given an array A of N integers we draw N discs in a 2D plane, such that i-th disc has center in (0,i) and a radius
Java 2*100%.
result is declared as long for a case codility doesn't test, namely 50k*50k intersections at one point.
class Solution {
public int solution(int[] A) {
int[] westEnding = new int[A.length];
int[] eastEnding = new int[A.length];
for (int i=0; i=0) eastEnding[i-A[i]]++; else eastEnding[0]++;
if ((long)i+A[i]10000000) return -1;
easts--;
wests-= westEnding[i];
}
return (int) result;
}
}