CoolFace
Datasetpublic

TheRealSamuel/LeetCodeProblem

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes564downloads
1{2    "id": 2423,3    "name": "minimum_deletions_to_make_array_divisible",4    "difficulty": "Hard",5    "link": "https://leetcode.com/problems/minimum-deletions-to-make-array-divisible/",6    "date": "1657411200000",7    "task_description": "You are given two positive integer arrays `nums` and `numsDivide`. You can delete any number of elements from `nums`. Return _the **minimum** number of deletions such that the **smallest** element in _`nums`_ **divides** all the elements of _`numsDivide`. If this is not possible, return `-1`. Note that an integer `x` divides `y` if `y % x == 0`. **Example 1:** ``` **Input:** nums = [2,3,2,4,3], numsDivide = [9,6,9,3,15] **Output:** 2 **Explanation:** The smallest element in [2,3,2,4,3] is 2, which does not divide all the elements of numsDivide. We use 2 deletions to delete the elements in nums that are equal to 2 which makes nums = [3,4,3]. The smallest element in [3,4,3] is 3, which divides all the elements of numsDivide. It can be shown that 2 is the minimum number of deletions needed. ``` **Example 2:** ``` **Input:** nums = [4,3,6], numsDivide = [8,2,6,10] **Output:** -1 **Explanation:** We want the smallest element in nums to divide all the elements of numsDivide. There is no way to delete elements from nums to allow this. ``` **Constraints:** `1 <= nums.length, numsDivide.length <= 105` `1 <= nums[i], numsDivide[i] <= 109`",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "nums = [2,3,2,4,3], numsDivide = [9,6,9,3,15]",12            "output": "2 "13        },14        {15            "label": "Example 2",16            "input": "nums = [4,3,6], numsDivide = [8,2,6,10]",17            "output": "-1 "18        }19    ],20    "private_test_cases": [],21    "haskell_template": "minOperations :: [Int] -> [Int] -> Int\nminOperations nums numsDivide ",22    "ocaml_template": "let minOperations (nums: int list) (numsDivide: int list) : int =  ",23    "scala_template": "def minOperations(nums: List[Int],numsDivide: List[Int]): Int = { \n    \n}",24    "java_template": "public static int minOperations(List<Integer> nums, List<Integer> numsDivide) {\n\n}",25    "python_template": "class Solution(object):\n    def minOperations(self, nums, numsDivide):\n        \"\"\"\n        :type nums: List[int]\n        :type numsDivide: List[int]\n        :rtype: int\n        \"\"\"\n        "26}