Mini-Max Sum

  • + 0 comments

    Tried all hard to get to this -

    using System.CodeDom.Compiler;
    using System.Collections.Generic;
    using System.Collections;
    using System.ComponentModel;
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.IO;
    using System.Linq;
    using System.Reflection;
    using System.Runtime.Serialization;
    using System.Text.RegularExpressions;
    using System.Text;
    using System;
    
    class Result
    {
        
         * The function accepts INTEGER_ARRAY arr as parameter.
         */
    
        public static void miniMaxSum(List<int> arr)
        {
            List<long> sumOfNumbers = new List<long>();
            for(int i =0; i < arr.Count(); i ++) {
                List<int> anotherAray = new List<int>(arr);
                anotherAray.RemoveAt(i);
                sumOfNumbers.Add(anotherAray.Sum(x => (long)x));
            }
            Console.WriteLine($"{sumOfNumbers.Order().First()} {sumOfNumbers.Order().Last()}");
        }
    }
    
    class Solution
    {
        public static void Main(string[] args)
        {
            List<int> arr = Console.ReadLine().TrimEnd().Split(' ').ToList().Select(arrTemp => Convert.ToInt32(arrTemp)).ToList();
    
            Result.miniMaxSum(arr);
        }
    }