• + 1 comment

    Agreed , as all the above built-in functions [ConvertAll(),Min,Max] are internally using loops. they are sugar coated functions for developer.

    Below is my solution for uses 2 reasonable loops and print the result as expected. kindly suggest if we can improve further the below code.

        long min = 0;
        long max = 0;
        var isFirstloop = true;
    
        for (int i = 0; i < arr.Count; i++)
        {
            long tempCount = 0;
            for (int j = 0; j < arr.Count; j++)
            {
                if (i != j)
                {
                    tempCount += arr[j];
    
                }
            }
    
            if (isFirstloop)
            {
    
                min = tempCount;
                max = tempCount;
                isFirstloop = false;
            }
            else
            {               
                if (tempCount < min)
                {
                    min = tempCount;
    
                }
                else if (tempCount > max)
                {
                    max = tempCount;
                }
            }
        }
    
        Console.WriteLine($"{min} {max}");
        Console.ReadKey();