Two Pointer Approach || Method of loading Previous largest and smallest element
Intuition\r\n    To print difference between first 2 largest element and smallest \r\n    element of the given array.\r\n\r\n# Approach\r\n1. Initialize min and
# Intuition\r\n    To print difference between first 2 largest element and smallest \r\n    element of the given array.\r\n\r\n# Approach\r\n1. Initialize min and max of a and b represents previous and current maximum & minimum value.\r\n2. By made an single traversal load the min and max value. Then make the given process.\r\n3. Finally return the result.\r\n\r\n# Complexity\r\n- Time complexity: 3ms\r\n\r\n- Space complexity: 44.96mb\r\n\r\n# Code\r\n```\r\nclass Solution {\r\n    public int maxProductDifference(int[] nums) {\r\n    int n=nums.length;\r\n    int mina=10001,minb=10001,maxa=0,maxb=0;\r\n    for(int i=0;i<n;i++){\r\n        if(mina>nums[i]){\r\n            minb=mina;\r\n            mina=nums[i];\r\n        }else if(minb>nums[i])\r\n            minb=nums[i];\r\n        if(maxa<nums[i]){\r\n            maxb=maxa;\r\n            maxa=nums[i];\r\n        }else if(maxb<nums[i])\r\n            maxb=nums[i];\r\n    }\r\n    return (maxa*maxb)-(minb*mina);   \r\n    }\r\n}\r\n```
['Array', 'Sorting', 'Java']