Print two space-separated long integers denoting the respective minimum and maximum values that can be calculated by summing exactly four of the five integers.
Stuck at understanding a hint given in question.
Hint: Beware of integer overflow! Use 64-bit Integer.
Code:
string[] arr_temp = Console.ReadLine().Split(' ');
int[] arr = Array.ConvertAll(arr_temp, Int32.Parse);
arr = arr.OrderBy(i => i).ToArray();
int mine = arr[0];
int maxe = arr[arr.Length - 1];
int sum = 0;
for (int i = 0; i < arr.Length; i++)
{
if(arr[i]>=1 && arr[i]<=Math.Pow(10,9))
sum+= arr[i];
}
Console.WriteLine((sum-maxe) + " " + (sum-mine));
Note : The motive of posting here, is to improve learning over code review, solution is already on multiple blogs.