Simple Java Solution
Code\r\n\r\nclass Solution {\r\n    public int maxProductDifference(int[] nums) {\r\n         int largest = Integer.MIN_VALUE;\r\n        int secondLargest = In
# Code\r\n```\r\nclass Solution {\r\n    public int maxProductDifference(int[] nums) {\r\n         int largest = Integer.MIN_VALUE;\r\n        int secondLargest = Integer.MIN_VALUE;\r\n        int smallest = Integer.MAX_VALUE;\r\n        int secondSmallest = Integer.MAX_VALUE;\r\n\r\n        for (int num : nums) {\r\n            if (num >= largest) {\r\n                secondLargest = largest;\r\n                largest = num;\r\n            } else if (num > secondLargest) {\r\n                secondLargest = num;\r\n            }\r\n\r\n            if (num <= smallest) {\r\n                secondSmallest = smallest;\r\n                smallest = num;\r\n            } else if (num < secondSmallest) {\r\n                secondSmallest = num;\r\n            }\r\n        }\r\n\r\n        return largest * secondLargest - smallest * secondSmallest;\r\n    }\r\n}\r\n```
['Java']