Given the array of integers <code>nums</code>, you will choose two different indices <code>i</code> and <code>j</code> of that array. <em>Return the maximum value of</em> <code>(nums[i]-1)*(nums[j]-1)</code>.
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [3,4,5,2]
<strong>Output:</strong> 12 
<strong>Explanation:</strong> If you choose the indices i=1 and j=2 (indexed from 0), you will get the maximum value, that is, (nums[1]-1)*(nums[2]-1) = (4-1)*(5-1) = 3*4 = 12. 
</pre>

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

<pre>
<strong>Input:</strong> nums = [1,5,4,5]
<strong>Output:</strong> 16
<strong>Explanation:</strong> Choosing the indices i=1 and j=3 (indexed from 0), you will get the maximum value of (5-1)*(5-1) = 16.
</pre>

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

<pre>
<strong>Input:</strong> nums = [3,7]
<strong>Output:</strong> 12
</pre>

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

<ul>
	<li><code>2 &lt;= nums.length &lt;= 500</code></li>
	<li><code>1 &lt;= nums[i] &lt;= 10^3</code></li>
</ul>

class Solution {
public:
int maxvalue(vector<int>&nums)
{
    int firstmax=INT_MIN;
    int secondmax=INT_MIN;
    for(int i=0;i<nums.size();i++)
    {
        if(nums[i]>firstmax)
        {
            secondmax=firstmax;
            firstmax=nums[i];
        }
        else if(nums[i]>=secondmax )
        {
            secondmax=nums[i];
        }
       
    }
        
        int value1=firstmax-1;
        int value2=secondmax-1;
        int result=value1*value2;
        return result;
}
    int maxProduct(vector<int>& nums) {
        /*int maxi=0;
        for(int i=0;i<nums.size()-1;i++)
        {
            for(int j=i+1;j<arr.size();j++)
            {
                 maxi=(nums[i]-1)*(nums[j]-1);
            }
        }
        */
         return maxvalue(nums);
    }
};
12600