Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes402downloads
minimum-size-subarray-in-infinite-array.json35 linesDownload Raw Back to root
1{2  "id": 3141,3  "name": "minimum-size-subarray-in-infinite-array",4  "difficulty": "Medium",5  "link": "https://leetcode.com/problems/minimum-size-subarray-in-infinite-array/",6  "date": "2023-09-24",7  "task_description": "You are given a **0-indexed** array `nums` and an integer `target`. A **0-indexed** array `infinite_nums` is generated by infinitely appending the elements of `nums` to itself. Return _the length of the **shortest** subarray of the array _`infinite_nums`_ with a sum equal to _`target`_._ If there is no such subarray return `-1`. **Example 1:** ``` **Input:** nums = [1,2,3], target = 5 **Output:** 2 **Explanation:** In this example infinite_nums = [1,2,3,1,2,3,1,2,...]. The subarray in the range [1,2], has the sum equal to target = 5 and length = 2. It can be proven that 2 is the shortest length of a subarray with sum equal to target = 5. ``` **Example 2:** ``` **Input:** nums = [1,1,1,2,3], target = 4 **Output:** 2 **Explanation:** In this example infinite_nums = [1,1,1,2,3,1,1,1,2,3,1,1,...]. The subarray in the range [4,5], has the sum equal to target = 4 and length = 2. It can be proven that 2 is the shortest length of a subarray with sum equal to target = 4. ``` **Example 3:** ``` **Input:** nums = [2,4,6,8], target = 3 **Output:** -1 **Explanation:** In this example infinite_nums = [2,4,6,8,2,4,6,8,...]. It can be proven that there is no subarray with sum equal to target = 3. ``` **Constraints:** `1 <= nums.length <= 105` `1 <= nums[i] <= 105` `1 <= target <= 109`",8  "test_case": [9    {10      "label": "Example 1",11      "input": "nums = [1,2,3], target = 5",12      "output": "2 "13    },14    {15      "label": "Example 2",16      "input": "nums = [1,1,1,2,3], target = 4",17      "output": "2 "18    },19    {20      "label": "Example 3",21      "input": "nums = [2,4,6,8], target = 3",22      "output": "-1 "23    }24  ],25  "constraints": [26    "1 <= nums.length <= 105",27    "1 <= nums[i] <= 105",28    "1 <= target <= 109"29  ],30  "python_template": "class Solution(object):\n    def minSizeSubarray(self, nums, target):\n        \"\"\"\n        :type nums: List[int]\n        :type target: int\n        :rtype: int\n        \"\"\"\n        ",31  "java_template": "class Solution {\n    public int minSizeSubarray(int[] nums, int target) {\n        \n    }\n}",32  "metadata": {33    "func_name": "minSizeSubarray"34  }35}