Minimum Average of Smallest and Largest Elements Using Built-in Functions and 2 Pointers
IntuitionThe problem requires us to iteratively remove the smallest and largest elements from the array, compute their average, and return the minimum average o
## Intuition
The problem requires us to iteratively remove the smallest and largest elements from the array, compute their average, and return the minimum average obtained in the process. The key observations are:

- Since we remove two elements at a time, the number of iterations is `n/2`.
- Sorting the array initially allows easy access to the smallest and largest elements.
- A min-max approach ensures that we systematically eliminate extreme values while maintaining efficiency.

## Approach
1. **Sort the Array:**
   - Sorting the input `nums` array simplifies the process of extracting the smallest and largest values in each step.
2. **Use Two Pointers:**
   - Maintain two pointers: one at the start (`left`) and one at the end (`right`) of the sorted list.
   - Compute the average of the values at these pointers and store it in a list `averages`.
   - Move the `left` pointer forward and `right` pointer backward after each computation.
3. **Find the Minimum Average:**
   - After iterating `n/2` times, return the minimum value from `averages`.

## Complexity
- **Time Complexity:**
  - Sorting takes `O(n log n)`, and iterating `n/2` times takes `O(n)`, so the overall complexity is **`O(n log n)`**.
- **Space Complexity:**
  - We use an additional array `averages` of size `O(n/2)`, but this can be optimized to `O(1)` by tracking the minimum value directly. Hence, the space complexity is **`O(1)`**.

### Explanation of the Code:
1. **Sorting the Input:** This allows direct access to min and max elements.
2. **Two-Pointer Approach:** Iteratively compute averages from both ends.
3. **Tracking Minimum Average:** Instead of storing all averages, we update `min_avg` directly to optimize space usage.

### Edge Cases Considered:
- Smallest case where `n = 2`.
- All elements are the same.
- Elements are already sorted.
- Elements are in decreasing order.

# Code
```python3 []
class Solution:
    def minimumAverage(self, nums: List[int]) -> float:
        final_avg = float('inf')    # Corrected initialization
        while len(nums) > 1:        # Ensuring at least two elements exist
            big = max(nums)
            small = min(nums)
            avg = (big + small) / 2
            final_avg = min(avg, final_avg)
            nums.remove(big)        # Remove largest element
            nums.remove(small)      # Remove smallest element
        return final_avg            # Return the minimum average found
```
['Array', 'Two Pointers', 'Sorting', 'Python3']