[코테 풀이] Maximum Product Difference Between Two Pairs

시내·2024년 6월 16일
0

Q_1913) Maximum Product Difference Between Two Pairs

출처 : https://leetcode.com/problems/maximum-product-difference-between-two-pairs/

class Solution {
    public int maxProductDifference(int[] nums) {
        ArrayList<Integer> num = new ArrayList<>();
        for(int n : nums) num.add(n);
        Collections.sort(num);
        
        return (num.get(num.size()-1)*num.get(num.size()-2)) - (num.get(0)*num.get(1));
    }
}
profile
contact 📨 ksw08215@gmail.com

0개의 댓글