Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes399downloads
count-array-pairs-divisible-by-k.json31 linesDownload Raw Back to root
1{2  "id": 2301,3  "name": "count-array-pairs-divisible-by-k",4  "difficulty": "Hard",5  "link": "https://leetcode.com/problems/count-array-pairs-divisible-by-k/",6  "date": "2022-02-13",7  "task_description": "Given a **0-indexed** integer array `nums` of length `n` and an integer `k`, return _the **number of pairs**_ `(i, j)` _such that:_ `0 <= i < j <= n - 1` _and_ `nums[i] * nums[j]` _is divisible by_ `k`. **Example 1:** ``` **Input:** nums = [1,2,3,4,5], k = 2 **Output:** 7 **Explanation:** The 7 pairs of indices whose corresponding products are divisible by 2 are (0, 1), (0, 3), (1, 2), (1, 3), (1, 4), (2, 3), and (3, 4). Their products are 2, 4, 6, 8, 10, 12, and 20 respectively. Other pairs such as (0, 2) and (2, 4) have products 3 and 15 respectively, which are not divisible by 2. ``` **Example 2:** ``` **Input:** nums = [1,2,3,4], k = 5 **Output:** 0 **Explanation:** There does not exist any pair of indices whose corresponding product is divisible by 5. ``` **Constraints:** `1 <= nums.length <= 105` `1 <= nums[i], k <= 105`",8  "test_case": [9    {10      "label": "Example 1",11      "input": "nums = [1,2,3,4,5], k = 2",12      "output": "7 "13    },14    {15      "label": "Example 2",16      "input": "nums = [1,2,3,4], k = 5",17      "output": "0 "18    }19  ],20  "constraints": [21    "0 <= i < j <= n - 1 and",22    "nums[i] * nums[j] is divisible by k.",23    "1 <= nums.length <= 105",24    "1 <= nums[i], k <= 105"25  ],26  "python_template": "class Solution(object):\n    def countPairs(self, nums, k):\n        \"\"\"\n        :type nums: List[int]\n        :type k: int\n        :rtype: int\n        \"\"\"\n        ",27  "java_template": "class Solution {\n    public long countPairs(int[] nums, int k) {\n        \n    }\n}",28  "metadata": {29    "func_name": "countPairs"30  }31}