| 1 | |
| 2 | class Solution { |
| 3 | public: |
| 4 | int maximumUniqueSubarray(vector<int>& nums) { |
| 5 | ios::sync_with_stdio(false); |
| 6 | cin.tie(nullptr); |
| 7 | |
| 8 | set<long long int> a; |
| 9 | long long int i=0,ans=0,j=0,curr=0,n=nums.size(); |
| 10 | while (j<n){ |
| 11 | if (a.find(nums[j])==a.end()){ |
| 12 | a.insert(nums[j]); |
| 13 | curr+=nums[j]; |
| 14 | ans = max(ans,curr); |
| 15 | j++; |
| 16 | } |
| 17 | else{ |
| 18 | a.erase(nums[i]); |
| 19 | curr-=nums[i]; |
| 20 | i++; |
| 21 | } |
| 22 | } |
| 23 | return ans; |
| 24 | } |
| 25 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected