Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3aa8fa8

Browse files
3487. Maximum Unique Subarray Sum After Deletion
1 parent 2c414e0 commit 3aa8fa8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# 3487. Maximum Unique Subarray Sum After Deletion
2+
def maxSum(nums):
3+
data = set()
4+
if len(nums) == 1:
5+
return nums[0]
6+
for i in nums:
7+
if i not in data and i > 0:
8+
data.add(i)
9+
if i < 0:
10+
data.add(max(nums))
11+
total_data = sum(data)
12+
return total_data
13+
14+
15+
arr = list(map(int, input("Enter the array:").split(',')))
16+
print(maxSum(arr))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /