✅✅ 1 Loop Solution || Without Sorting || 100% efficient ✅✅
\r\n\r\n# Complexity\r\n- Time complexity: O(N)\r\n Add your time complexity here, e.g. O(n) \r\n\r\n- Space complexity: O(1)\r\n Add your space complexity here
\r\n\r\n# Complexity\r\n- Time complexity: O(N)\r\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\r\n\r\n- Space complexity: O(1)\r\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\r\n\r\n# Code\r\n```\r\nclass Solution {\r\n    public int maxProductDifference(int[] nums) {\r\n      int max1=Integer.MIN_VALUE;\r\n      int max2=Integer.MIN_VALUE;\r\n      int min1=Integer.MAX_VALUE;\r\n      int min2=Integer.MAX_VALUE;\r\n\r\n      for(int n : nums){\r\n          if(n>max1){\r\n              max2=max1;\r\n              max1=n;\r\n          }\r\n          else if(n>max2){\r\n              max2=n;\r\n          }\r\n\r\n          if(n<min1){\r\n              min2=min1;\r\n              min1=n;\r\n          }\r\n          else if(n<min2){\r\n              min2=n;\r\n          }\r\n      }\r\n\r\n      return (max1*max2)-(min1*min2);\r\n\r\n\r\n    }\r\n}\r\n```
['Array', 'Java']