Skip to content

Commit c31eb2e

Browse files
authored
Merge pull request SjxSubham#36 from emcc2302/main
Solving 3487. Maximum Unique Subarray Sum After Deletion #### Solved
2 parents 5698bbd + 37266a1 commit c31eb2e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public:
3+
int maxSum(vector<int>& nums) {
4+
unordered_set<int> s;
5+
int temp = INT_MIN;
6+
for(int i: nums){
7+
if(i>0) s.insert(i);
8+
else{
9+
temp = max(temp,i);
10+
}
11+
}
12+
return s.empty()?temp:accumulate(s.begin(), s.end(), 0);
13+
}
14+
};

0 commit comments

Comments
 (0)