Java O(n) - Sliding Window + HashSet
\nclass Solution {\n    public int maximumUniqueSubarray(int[] nums) {\n        \n        Set<Integer> set =  new HashSet();\n        \n      int sum =0, ans =0
```\nclass Solution {\n    public int maximumUniqueSubarray(int[] nums) {\n        \n        Set<Integer> set =  new HashSet();\n        \n      int sum =0, ans =0;\n        int j = 0;\n        \n        int i = 0;\n        \n        while(i<nums.length && j<nums.length){\n            \n            if(!set.contains(nums[j])){\n                \n                sum+=nums[j];\n                ans = Math.max(sum,ans);\n                set.add(nums[j++]);\n            }else{\n                \n                sum = sum-nums[i];\n                set.remove(nums[i++]);\n            }\n        }\n\n        return ans;\n    }\n}\n```
['Two Pointers']