<p>The <strong>product difference</strong> between two pairs <code>(a, b)</code> and <code>(c, d)</code> is defined as <code>(a * b) - (c * d)</code>.</p>

<ul>
	<li>For example, the product difference between <code>(5, 6)</code> and <code>(2, 7)</code> is <code>(5 * 6) - (2 * 7) = 16</code>.</li>
</ul>

<p>Given an integer array <code>nums</code>, choose four <strong>distinct</strong> indices <code>w</code>, <code>x</code>, <code>y</code>, and <code>z</code> such that the <strong>product difference</strong> between pairs <code>(nums[w], nums[x])</code> and <code>(nums[y], nums[z])</code> is <strong>maximized</strong>.</p>

<p>Return <em>the <strong>maximum</strong> such product difference</em>.</p>

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

<pre>
<strong>Input:</strong> nums = [5,6,2,7,4]
<strong>Output:</strong> 34
<strong>Explanation:</strong> We can choose indices 1 and 3 for the first pair (6, 7) and indices 2 and 4 for the second pair (2, 4).
The product difference is (6 * 7) - (2 * 4) = 34.
</pre>

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

<pre>
<strong>Input:</strong> nums = [4,2,5,9,7,4,8]
<strong>Output:</strong> 64
<strong>Explanation:</strong> We can choose indices 3 and 6 for the first pair (9, 8) and indices 1 and 5 for the second pair (2, 4).
The product difference is (9 * 8) - (2 * 4) = 64.
</pre>

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

<ul>
	<li><code>4 &lt;= nums.length &lt;= 10<sup>4</sup></code></li>
	<li><code>1 &lt;= nums[i] &lt;= 10<sup>4</sup></code></li>
</ul>
class Solution:
    def maxProductDifference(self, nums: List[int]) -> int:
        # nums = sorted(nums)
        # firstPair1 = nums[len(nums) - 1]
        # firstPair2 = nums[len(nums) - 2]
        # secondPair1 = nums[0]
        # secondPair2 = nums[1]
        # maxDiff = (firstPair1 * firstPair2 ) - (secondPair1 * secondPair2)
        # return maxDiff


        maxNum1 = float('-inf') #biggest number 
        maxNum2 = float('-inf') # second biggest number 

        minNum1 = float('inf') #smallest number 
        minNum2 = float('inf') #second smallest number 

        for i in nums: 
            if i > maxNum1: 
                maxNum2 = maxNum1 
                maxNum1 = i 
            elif i > maxNum2: 
                maxNum2 = i

            
            if i < minNum1: 
               minNum2 = minNum1 
               minNum1 = i
            elif i < minNum2: 
                minNum2 = i




            # print(maxNum1)
            # print(maxNum2)
            # print(minNum1)
            # print(minNum2)
            # print("break")

            
        

        maxDiff = (maxNum1 * maxNum2) - (minNum1 * minNum2)

        return maxDiff
            

125