CoolFace
Datasetpublic

TheRealSamuel/LeetCodeProblem

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes564downloads
1{2    "id": 3788,3    "name": "maximum_unique_subarray_sum_after_deletion",4    "difficulty": "Easy",5    "link": "https://leetcode.com/problems/maximum-unique-subarray-sum-after-deletion/",6    "date": "2025-03-09 00:00:00",7    "task_description": "You are given an integer array `nums`. You are allowed to delete any number of elements from `nums` without making it **empty**. After performing the deletions, select a subarray of `nums` such that: All elements in the subarray are **unique**. The sum of the elements in the subarray is **maximized**. Return the **maximum sum** of such a subarray. **Example 1:** **Input:** nums = [1,2,3,4,5] **Output:** 15 **Explanation:** Select the entire array without deleting any element to obtain the maximum sum. **Example 2:** **Input:** nums = [1,1,0,1,1] **Output:** 1 **Explanation:** Delete the element `nums[0] == 1`, `nums[1] == 1`, `nums[2] == 0`, and `nums[3] == 1`. Select the entire array `[1]` to obtain the maximum sum. **Example 3:** **Input:** nums = [1,2,-1,-2,1,0,-1] **Output:** 3 **Explanation:** Delete the elements `nums[2] == -1` and `nums[3] == -2`, and select the subarray `[2, 1]` from `[1, 2, 1, 0, -1]` to obtain the maximum sum. **Constraints:** `1 <= nums.length <= 100` `-100 <= nums[i] <= 100`",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "nums = [1,2,3,4,5]",12            "output": "15 "13        },14        {15            "label": "Example 2",16            "input": "nums = [1,1,0,1,1]",17            "output": "1 "18        },19        {20            "label": "Example 3",21            "input": "nums = [1,2,-1,-2,1,0,-1]",22            "output": "3 "23        }24    ],25    "private_test_cases": [26        {27            "input": [28                -78,29                12,30                44,31                52,32                -46,33                -75,34                -71,35                13,36                53,37                -100,38                19,39                11,40                57,41                67,42                69,43                96,44                -95,45                6,46                71,47                29,48                -13,49                -69,50                -29,51                -41,52                -66,53                -87,54                -18,55                37,56                -2,57                -85,58                -59,59                49,60                -21,61                90,62                41,63                -91,64                51,65                82,66                -89,67                -30,68                -61,69                -44,70                -49,71                -45,72                17,73                30,74                9,75                -9276            ],77            "output": 100578        },79        {80            "input": [81                -32,82                83,83                14,84                91,85                -80,86                24,87                64,88                -43,89                -16,90                -96,91                -25,92                44,93                59,94                89,95                -78,96                87,97                -4098            ],99            "output": 555100        },101        {102            "input": [103                90,104                -4,105                4,106                54,107                -3,108                30,109                39,110                42,111                11,112                18,113                32,114                46,115                79,116                -86,117                36,118                57,119                33,120                -27,121                13,122                50,123                -45,124                -2,125                80,126                53,127                96,128                21,129                -14,130                -94,131                93,132                -82,133                2,134                12,135                -37,136                -87,137                48,138                -78,139                -92,140                35,141                -53,142                -1143            ],144            "output": 1074145        },146        {147            "input": [148                94,149                -66,150                100,151                54,152                57,153                30,154                98,155                -60156            ],157            "output": 433158        },159        {160            "input": [161                93,162                49,163                -73,164                -47,165                -75,166                -72,167                22,168                20,169                -81,170                76,171                66,172                -88,173                50,174                75,175                2,176                65,177                4,178                -92,179                -7,180                29,181                33,182                -36,183                -78,184                -1,185                24,186                11,187                47,188                -64,189                73,190                -50,191                -33192            ],193            "output": 739194        }195    ],196    "haskell_template": "maxSum :: [Int] -> Int\nmaxSum nums ",197    "ocaml_template": "let maxSum (nums: int list) : int =  ",198    "scala_template": "def maxSum(nums: List[Int]): Int = { \n    \n}",199    "java_template": "class Solution {\n    public int maxSum(int[] nums) {\n        \n    }\n}",200    "python_template": "class Solution(object):\n    def maxSum(self, nums):\n        \"\"\"\n        :type nums: List[int]\n        :rtype: int\n        \"\"\"\n        "201}