JAVA || Clean & Concise & Optimal Code || Sliding Window Approach || 6ms Time || 95% Faster Solution
\nclass Solution {\n    public int maximumUniqueSubarray(int[] nums) {\n        \n        int maxSum = 0;\n        int[] sum = new int[nums.length + 1];\n      
```\nclass Solution {\n    public int maximumUniqueSubarray(int[] nums) {\n        \n        int maxSum = 0;\n        int[] sum = new int[nums.length + 1];\n        int[] index = new int[10001];\n        \n        for (int i = 0, j = 0; i < nums.length; i++) {\n            j = Math.max (j, index[nums[i]]);\n            sum[i + 1] = sum[i] + nums[i];\n            maxSum = Math.max (maxSum, sum[i + 1] - sum[j]);\n            index[nums[i]] = i + 1;\n        }\n        \n        return maxSum;\n    }\n}\n```\n\nPlease help to **UPVOTE** if this post is useful for you.\nIf you have any questions, feel free to comment below.\n\n**LOVE CODING :)\nHAPPY CODING :)\nHAPPY LEARNING :)**
['Sliding Window', 'Java']