O(n) Java Sliding Window Solution
\n    public int maximumUniqueSubarray(int[] nums) {\n        int l =0, r = 0, length = nums.length, sum = 0;\n        int[] map = new int[10001];\n        int 
```\n    public int maximumUniqueSubarray(int[] nums) {\n        int l =0, r = 0, length = nums.length, sum = 0;\n        int[] map = new int[10001];\n        int ans = 0;\n        while (r < length) {\n            map[nums[r]]++;\n            sum += nums[r];\n            r++;\n            while (map[nums[r - 1]] >= 2) {\n                map[nums[l]]--;\n                sum -= nums[l];\n                l++;\n            }\n            ans = Math.max(ans, sum);\n        }\n        return ans;\n    }\n```
['Java']