-
Notifications
You must be signed in to change notification settings - Fork 0
/
hacker_rank_1.cs
50 lines (39 loc) · 1007 Bytes
/
hacker_rank_1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
class HackerRank
{
public static void miniMaxSum(List<int> arr)
{
int max, min, length;
long maxSum, minSum;
max = arr[0];
min = arr[0];
maxSum = 0;
minSum = 0;
length = arr.Count;
for (int i = 0; i < length; i++)
{
if (arr[i] > max || arr[i] == max)
{
max = arr[i];
}
if (arr[i] < min || arr[i] == min)
{
min = arr[i];
}
}
for (int i = 0; i < length; i++)
{
maxSum += arr[i];
minSum += arr[i];
}
Console.WriteLine("{0} {1}", maxSum - max, minSum - min);
}
public static void Main(string[] args){
var bigCities = new List<int>()
{
5,5,5,5,5
};
miniMaxSum(bigCities);
}
}