You are viewing a single comment's thread. Return to all comments →
My C# Solution
Revised code to pass Test 13 with input "5 5 5 5 5"
public static void miniMaxSum(List<int> arr) { long miniSum = 0, maxSum = 0, miniNum = arr.Min(), maxNum = arr.Max(); int minCount = 0, maxCount = 0; foreach (long num in arr) { if (num==miniNum || num<maxNum) { if (++minCount<=4) miniSum+=num; } if (num>miniNum || num==maxNum) { if (++maxCount<=4) maxSum+=num; } } Console.Write(miniSum.ToString()+" "+maxSum.ToString()); }
Seems like cookies are disabled on this browser, please enable them to open this website
Mini-Max Sum
You are viewing a single comment's thread. Return to all comments →
My C# Solution
Revised code to pass Test 13 with input "5 5 5 5 5"