EASY AND UNDERSTANDABLE C++ CODE
\nclass Solution {\npublic:\n    int lengthOfLongestSubarray(vector<int>& s) \n    {\n        int i = 0, j = 0;\n        int sum=0;\n        int maxsum = 0;    
```\nclass Solution {\npublic:\n    int lengthOfLongestSubarray(vector<int>& s) \n    {\n        int i = 0, j = 0;\n        int sum=0;\n        int maxsum = 0;    \n        unordered_map<int,int> mp;\n        \n        while(j < s.size())\n        {\t\n            mp[s[j]]++;\n            sum=sum+s[j];\n            \n            if(mp.size() == j-i+1)\n            {\n                maxsum = max(maxsum,sum);\n            }\n            else if(mp.size()< j-i+1)\n            {\n                while(mp.size() < j-i+1)\n                {\n                    mp[s[i]]--;\n                    sum= sum-s[i];\n                    if(mp[s[i]] == 0)\n                    {\n                        mp.erase(s[i]);\n                    }\n                    i++;\n                }\n            }\n            \n            j++;\n        }\n\n        return maxsum;\n    \n    }    \n    int maximumUniqueSubarray(vector<int>& nums) {\n        \n        return lengthOfLongestSubarray(nums);\n    }\n};\n```
['C', 'Sliding Window']