JAVA_LeetCode 3487_Maximum Unique Subarray Sum After Deletion 풀이 class Solution { public int maxSum(int[] nums) { // set으로 중복을 제외하고 해당 수가 합이 최대화가 되기 위해 음수를 제외한다. int sum = 0, max = Integer.MIN_VALUE; Set set = new HashSet(); for(int num : nums){ if(num > 0 && !set.contains(num)){ sum += num; set.add(num); }else if(num <= 0) max = Math.max(max, num); } return sum == 0 ?
max : sum; } } * 출처 https://leetcode.com/problems/maximum-unique-subarray-sum-after-deletion...