Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shivani13121007/12da48354342c50e1680105dbd0e4eb2 to your computer and use it in GitHub Desktop.
Save Shivani13121007/12da48354342c50e1680105dbd0e4eb2 to your computer and use it in GitHub Desktop.
Maximum Product Difference Between Two Pairs
class Solution {
public int maxProductDifference(int[] nums) {
int n = nums.length;
Arrays.sort(nums);
int a = nums[0];
int b = nums[1];
int c = nums[n-1];
int d = nums[n-2];
int res = Math.abs((a*b) - (c*d));
return res;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment