Easy Java solution with linear time complexity O(n) with constant space O(1)
Intuition\n Describe your first thoughts on how to solve this problem. \n    Easy if else conditions logic\n\n# Approach\n Describe your approach to solving the
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n    Easy if else conditions logic\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(1)\n\n# Code\n```\nclass Solution {\n    public int maxProductDifference(int[] nums) {\n        int maxi1=Integer.MIN_VALUE;\n        int maxi2=Integer.MIN_VALUE;\n        int mini1=Integer.MAX_VALUE;\n        int mini2=Integer.MAX_VALUE;\n        for (int i : nums) {\n            if (i >= maxi1) {\n                maxi2 = maxi1;\n                maxi1 = i;\n            } else if (i > maxi2)\n                maxi2 = i;\n\n            if (i <= mini1) {\n                mini2 = mini1;\n                mini1 = i;\n            } else if (i < mini2)\n                mini2 = i;\n        }\n        return (maxi1 * maxi2) - (mini1 * mini2);\n    }\n}\n\n```
['Java']