문제: app.codility.com/programmers/lessons/5-prefix_sums/passing_cars/
int result = 0;
int zero = 0;
for (int i = 0; i < A.Length; i++)
{
if (A[i] == 1)
{
result = result + zero;
}
else
{
zero++;
}
}
if (result < 0 || result > 1000000000)
result = -1;
return result;
'공부하자 > Codility' 카테고리의 다른 글
[Codility] Lesson6. MaxProductOfThree (C#) (0) | 2020.11.20 |
---|---|
[Codility] Lesson6. Distinct (C#) (0) | 2020.11.20 |
[Codility] Lesson5. MinAvgTwoSlice (C#) (0) | 2020.11.17 |
[Codility] Lesson5. GenomicRangeQuery (C#) (0) | 2020.11.17 |
[Codility] Lesson5. CountDiv (C#) (0) | 2020.11.17 |