Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes399downloads
maximum-subarray-sum-with-length-divisible-by-k.json34 linesDownload Raw Back to root
1{2  "id": 3653,3  "name": "maximum-subarray-sum-with-length-divisible-by-k",4  "difficulty": "Medium",5  "link": "https://leetcode.com/problems/maximum-subarray-sum-with-length-divisible-by-k/",6  "date": "2024-12-01",7  "task_description": "You are given an array of integers `nums` and an integer `k`. Return the **maximum** sum of a subarray of `nums`, such that the size of the subarray is **divisible** by `k`. **Example 1:** **Input:** nums = [1,2], k = 1 **Output:** 3 **Explanation:** The subarray `[1, 2]` with sum 3 has length equal to 2 which is divisible by 1. **Example 2:** **Input:** nums = [-1,-2,-3,-4,-5], k = 4 **Output:** -10 **Explanation:** The maximum sum subarray is `[-1, -2, -3, -4]` which has length equal to 4 which is divisible by 4. **Example 3:** **Input:** nums = [-5,1,2,-3,4], k = 2 **Output:** 4 **Explanation:** The maximum sum subarray is `[1, 2, -3, 4]` which has length equal to 4 which is divisible by 2. **Constraints:** `1 <= k <= nums.length <= 2 * 105` `-109 <= nums[i] <= 109`",8  "test_case": [9    {10      "label": "Example 1",11      "input": "nums = [1,2], k = 1",12      "output": "3 "13    },14    {15      "label": "Example 2",16      "input": "nums = [-1,-2,-3,-4,-5], k = 4",17      "output": "-10 "18    },19    {20      "label": "Example 3",21      "input": "nums = [-5,1,2,-3,4], k = 2",22      "output": "4 "23    }24  ],25  "constraints": [26    "1 <= k <= nums.length <= 2 * 105",27    "-109 <= nums[i] <= 109"28  ],29  "python_template": "class Solution(object):\n    def maxSubarraySum(self, nums, k):\n        \"\"\"\n        :type nums: List[int]\n        :type k: int\n        :rtype: int\n        \"\"\"\n        ",30  "java_template": "class Solution {\n    public long maxSubarraySum(int[] nums, int k) {\n        \n    }\n}",31  "metadata": {32    "func_name": "maxSubarraySum"33  }34}