Sliding window & Two Pointers Pattern
the sum of unique "subArray" elemets is added\n\n# Code\njava []\nimport java.util.HashMap;\n\nclass Solution {\n    public int maximumUniqueSubarray(int[] nums
the sum of unique "subArray" elemets is added\n\n# Code\n```java []\nimport java.util.HashMap;\n\nclass Solution {\n    public int maximumUniqueSubarray(int[] nums) {\n        HashMap<Integer, Integer> map = new HashMap<>();\n        int left = 0, right = 0, sum = 0, maxSum = 0;\n\n        while (right < nums.length) {\n            sum += nums[right];\n            map.put(nums[right], map.getOrDefault(nums[right], 0) + 1);\n\n            while (map.get(nums[right]) > 1) {\n                sum -= nums[left];\n                map.put(nums[left], map.get(nums[left]) - 1);\n                if (map.get(nums[left]) == 0) {\n                    map.remove(nums[left]);\n                }\n                left++;\n            }\n\n            maxSum = Math.max(maxSum, sum);\n            right++;\n        }\n\n        return maxSum;\n    }\n}\n\n```
['Java']