문제: app.codility.com/programmers/lessons/6-sorting/max_product_of_three/
List<int> ListA = new List<int>(A);
ListA.Sort();
if (ListA[A.Length - 1] < 0)
return ListA[A.Length - 1] * ListA[A.Length - 2] * ListA[A.Length - 3];
int pre = ListA[0] * ListA[1];
int post = ListA[A.Length - 2] * ListA[A.Length - 3];
int result = 0;
if (pre < post)
result = post * ListA[A.Length - 1];
else
result = pre * ListA[A.Length - 1];
return result;
'공부하자 > Codility' 카테고리의 다른 글
[Codility] Lesson6. Triangle (C#) (0) | 2020.11.20 |
---|---|
[Codility] Lesson6. NumberOfDiscIntersections (C#) (0) | 2020.11.20 |
[Codility] Lesson6. Distinct (C#) (0) | 2020.11.20 |
[Codility] Lesson5. PassingCars (C#) (0) | 2020.11.17 |
[Codility] Lesson5. MinAvgTwoSlice (C#) (0) | 2020.11.17 |