<p>Given an integer array <code>nums</code>, <em>find three numbers whose product is maximum and return the maximum product</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> nums = [1,2,3]
<strong>Output:</strong> 6
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> nums = [1,2,3,4]
<strong>Output:</strong> 24
</pre><p><strong class="example">Example 3:</strong></p>
<pre><strong>Input:</strong> nums = [-1,-2,-3]
<strong>Output:</strong> -6
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>3 &lt;= nums.length &lt;=&nbsp;10<sup>4</sup></code></li>
	<li><code>-1000 &lt;= nums[i] &lt;= 1000</code></li>
</ul>

class Solution {
    public:
        int maximumProduct(vector<int>& nums) 
            {
                    int first_max = INT_MIN ;
                            int second_max = INT_MIN ;
                                    int third_max = INT_MIN ;

                                            int first_min = INT_MAX ;
                                                    int second_min = INT_MAX ;

                                                            for( int i = 0 ; i < nums.size() ; i++ )
                                                                    {
                                                                                if( nums[i] < first_min )
                                                                                            {
                                                                                                            second_min = first_min ;
                                                                                                                            first_min = nums[i] ;
                                                                                                                                        }
                                                                                                                                                    else if( nums[i] < second_min )
                                                                                                                                                                    second_min = nums[i] ;
                                                                                                                                                                                if( nums[i] > first_max )
                                                                                                                                                                                            {
                                                                                                                                                                                                            third_max = second_max ;
                                                                                                                                                                                                                            second_max = first_max ;
                                                                                                                                                                                                                                            first_max = nums[i] ;
                                                                                                                                                                                                                                                        }
                                                                                                                                                                                                                                                                    else if( nums[i] > second_max )
                                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                                                third_max = second_max ;
                                                                                                                                                                                                                                                                                                                second_max = nums[i] ;
                                                                                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                                                                                                        else if( nums[i] > third_max )
                                                                                                                                                                                                                                                                                                                                                        third_max = nums[i] ;
                                                                                                                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                                                                                                                                        return max ( first_max * second_max * third_max , first_min * second_min * first_max );
                                                                                                                                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                                                                                                                                            };

        
    

30300