<p>You are given an array of <strong>unique</strong> integers <code>salary</code> where <code>salary[i]</code> is the salary of the <code>i<sup>th</sup></code> employee.</p>

<p>Return <em>the average salary of employees excluding the minimum and maximum salary</em>. Answers within <code>10<sup>-5</sup></code> of the actual answer will be accepted.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> salary = [4000,3000,1000,2000]
<strong>Output:</strong> 2500.00000
<strong>Explanation:</strong> Minimum salary and maximum salary are 1000 and 4000 respectively.
Average salary excluding minimum and maximum salary is (2000+3000) / 2 = 2500
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> salary = [1000,2000,3000]
<strong>Output:</strong> 2000.00000
<strong>Explanation:</strong> Minimum salary and maximum salary are 1000 and 3000 respectively.
Average salary excluding minimum and maximum salary is (2000) / 1 = 2000
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>3 &lt;= salary.length &lt;= 100</code></li>
	<li><code>1000 &lt;= salary[i] &lt;= 10<sup>6</sup></code></li>
	<li>All the integers of <code>salary</code> are <strong>unique</strong>.</li>
</ul>

class Solution:
    def average(self, salary: List[int]) -> float:
        # Initialize variables to store the sum, min, and max salary
        total_sum = 0
        min_salary = float('inf')
        max_salary = float('-inf')
        
        # Iterate through the salary list
        for sal in salary:
            # Update the total sum
            total_sum += sal
            
            # Update the min salary
            if sal < min_salary:
                min_salary = sal
                
            # Update the max salary
            if sal > max_salary:
                max_salary = sal
        
        # Calculate the adjusted sum by subtracting the min and max salaries
        adjusted_sum = total_sum - min_salary - max_salary
        
        # Calculate the number of salaries excluding the min and max
        num_salaries = len(salary) - 2
        
        # Calculate the average
        average_salary = adjusted_sum / num_salaries
        
        return average_salary

# Example usage:
solution = Solution()
print(solution.average([4000, 3000, 1000, 2000]))  # Output: 2500.0
print(solution.average([1000, 2000, 3000]))      # Output: 2000.0
15