Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes399downloads
destroy-sequential-targets.json35 linesDownload Raw Back to root
1{2  "id": 2548,3  "name": "destroy-sequential-targets",4  "difficulty": "Medium",5  "link": "https://leetcode.com/problems/destroy-sequential-targets/",6  "date": "2022-10-15",7  "task_description": "You are given a **0-indexed** array `nums` consisting of positive integers, representing targets on a number line. You are also given an integer `space`. You have a machine which can destroy targets. **Seeding** the machine with some `nums[i]` allows it to destroy all targets with values that can be represented as `nums[i] + c * space`, where `c` is any non-negative integer. You want to destroy the **maximum** number of targets in `nums`. Return_ the **minimum value** of _`nums[i]`_ you can seed the machine with to destroy the maximum number of targets._ **Example 1:** ``` **Input:** nums = [3,7,8,1,1,5], space = 2 **Output:** 1 **Explanation:** If we seed the machine with nums[3], then we destroy all targets equal to 1,3,5,7,9,... In this case, we would destroy 5 total targets (all except for nums[2]). It is impossible to destroy more than 5 targets, so we return nums[3]. ``` **Example 2:** ``` **Input:** nums = [1,3,5,2,4,6], space = 2 **Output:** 1 **Explanation:** Seeding the machine with nums[0], or nums[3] destroys 3 targets. It is not possible to destroy more than 3 targets. Since nums[0] is the minimal integer that can destroy 3 targets, we return 1. ``` **Example 3:** ``` **Input:** nums = [6,2,5], space = 100 **Output:** 2 **Explanation:** Whatever initial seed we select, we can only destroy 1 target. The minimal seed is nums[1]. ``` **Constraints:** `1 <= nums.length <= 105` `1 <= nums[i] <= 109` `1 <= space <= 109`",8  "test_case": [9    {10      "label": "Example 1",11      "input": "nums = [3,7,8,1,1,5], space = 2",12      "output": "1 "13    },14    {15      "label": "Example 2",16      "input": "nums = [1,3,5,2,4,6], space = 2",17      "output": "1 "18    },19    {20      "label": "Example 3",21      "input": "nums = [6,2,5], space = 100",22      "output": "2 "23    }24  ],25  "constraints": [26    "1 <= nums.length <= 105",27    "1 <= nums[i] <= 109",28    "1 <= space <= 109"29  ],30  "python_template": "class Solution(object):\n    def destroyTargets(self, nums, space):\n        \"\"\"\n        :type nums: List[int]\n        :type space: int\n        :rtype: int\n        \"\"\"\n        ",31  "java_template": "class Solution {\n    public int destroyTargets(int[] nums, int space) {\n        \n    }\n}",32  "metadata": {33    "func_name": "destroyTargets"34  }35}