TheRealSamuel/LeetCodeProblem
0564
1{2 "id": 2277,3 "name": "count_equal_and_divisible_pairs_in_an_array",4 "difficulty": "Easy",5 "link": "https://leetcode.com/problems/count-equal-and-divisible-pairs-in-an-array/",6 "date": "1644019200000",7 "task_description": "Given a **0-indexed** integer array `nums` of length `n` and an integer `k`, return _the **number of pairs**_ `(i, j)` _where_ `0 <= i < j < n`, _such that_ `nums[i] == nums[j]` _and_ `(i * j)` _is divisible by_ `k`. **Example 1:** ``` **Input:** nums = [3,1,2,2,2,1,3], k = 2 **Output:** 4 **Explanation:** There are 4 pairs that meet all the requirements: - nums[0] == nums[6], and 0 * 6 == 0, which is divisible by 2. - nums[2] == nums[3], and 2 * 3 == 6, which is divisible by 2. - nums[2] == nums[4], and 2 * 4 == 8, which is divisible by 2. - nums[3] == nums[4], and 3 * 4 == 12, which is divisible by 2. ``` **Example 2:** ``` **Input:** nums = [1,2,3,4], k = 1 **Output:** 0 **Explanation:** Since no value in nums is repeated, there are no pairs (i,j) that meet all the requirements. ``` **Constraints:** `1 <= nums.length <= 100` `1 <= nums[i], k <= 100`",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "nums = [3,1,2,2,2,1,3], k = 2",12 "output": "4 "13 },14 {15 "label": "Example 2",16 "input": "nums = [1,2,3,4], k = 1",17 "output": "0 "18 }19 ],20 "private_test_cases": [21 {22 "input": [23 [24 39,25 64,26 19,27 86,28 48,29 65,30 45,31 55,32 51,33 90,34 99,35 66,36 54,37 56,38 6,39 94,40 35,41 94,42 64,43 32,44 53,45 86,46 93,47 52,48 34,49 31,50 25,51 64,52 59,53 98,54 47,55 39,56 24,57 9,58 61,59 51,60 87,61 50,62 51,63 64,64 24,65 90,66 12,67 56,68 32,69 17,70 85,71 4,72 94,73 36,74 57,75 11,76 3877 ],78 7879 ],80 "output": 281 },82 {83 "input": [84 [85 89,86 76,87 44,88 59,89 85,90 4,91 36,92 41,93 95,94 7,95 7,96 80,97 32,98 4,99 88,100 29,101 64,102 9,103 9,104 66,105 30,106 55,107 3,108 76,109 9,110 52,111 59,112 81,113 74,114 36,115 71,116 31,117 68,118 48,119 89,120 51,121 89,122 31,123 86,124 61,125 34,126 10,127 87,128 82,129 93,130 38,131 53,132 75,133 62,134 15135 ],136 50137 ],138 "output": 2139 },140 {141 "input": [142 [143 51,144 95,145 17,146 82,147 66,148 47,149 58,150 48,151 73,152 61,153 47,154 33,155 14,156 31157 ],158 60159 ],160 "output": 0161 },162 {163 "input": [164 [165 24,166 6,167 83,168 7,169 58,170 10,171 71,172 69,173 93,174 9,175 98,176 28,177 8,178 75,179 94,180 32,181 82,182 69,183 48,184 85,185 13,186 26,187 29,188 41,189 74,190 50,191 49,192 10,193 82,194 16,195 70,196 19,197 37,198 46,199 6,200 27,201 42,202 54,203 74,204 16,205 94,206 37,207 24,208 20,209 36,210 77,211 42212 ],213 20214 ],215 "output": 2216 },217 {218 "input": [219 [220 60,221 87,222 53,223 86,224 48,225 16,226 60,227 83,228 74,229 3,230 10,231 89,232 88,233 2,234 88,235 73,236 73,237 84,238 20,239 97,240 38,241 34,242 37,243 23,244 35,245 89,246 18,247 49,248 45,249 83,250 82,251 10,252 30,253 28,254 81,255 44,256 63,257 68,258 28,259 55,260 26,261 42,262 63,263 83,264 97,265 96,266 51,267 15,268 64,269 75,270 29,271 13,272 29,273 14,274 46,275 30,276 77,277 48,278 3,279 66,280 8,281 17,282 27,283 61,284 81,285 13,286 74,287 3,288 56,289 39,290 28,291 85,292 64,293 3,294 14295 ],296 7297 ],298 "output": 7299 },300 {301 "input": [302 [303 49,304 56,305 1,306 59,307 45,308 95,309 19,310 51,311 59,312 43,313 5,314 70,315 80,316 63,317 49,318 65,319 89,320 80,321 32,322 4,323 36,324 58,325 51,326 13,327 43,328 6,329 16,330 25,331 20,332 50,333 45,334 17,335 51,336 29,337 1,338 88,339 7,340 79,341 100,342 19,343 18,344 85,345 81,346 26,347 32,348 4,349 90,350 10,351 70,352 19,353 69,354 17,355 42,356 99,357 46358 ],359 68360 ],361 "output": 3362 },363 {364 "input": [365 [366 34,367 29,368 46,369 82,370 30,371 12,372 4,373 92,374 62,375 15,376 87,377 95,378 72,379 87,380 14,381 1,382 22,383 25,384 14,385 98,386 1,387 23,388 38,389 60,390 1,391 2,392 22,393 50,394 9,395 50,396 20,397 10,398 60,399 2,400 5,401 15,402 64,403 90,404 58,405 72,406 27,407 46,408 79,409 38,410 43,411 81,412 11,413 55,414 37,415 44,416 79,417 87,418 75,419 20,420 27,421 90,422 28,423 15,424 32,425 76,426 70,427 12,428 76,429 43,430 37,431 92,432 99,433 25,434 36,435 42,436 27,437 48,438 17,439 3,440 100,441 77,442 59,443 68,444 75,445 31,446 2,447 15,448 48,449 41,450 14,451 94,452 55,453 88,454 70,455 20,456 2,457 20,458 40,459 10460 ],461 42462 ],463 "output": 7464 },465 {466 "input": [467 [468 5,469 72,470 2,471 83,472 85,473 14,474 59,475 35,476 15,477 22,478 29,479 53,480 2,481 80,482 50,483 45,484 59,485 47486 ],487 19488 ],489 "output": 0490 },491 {492 "input": [493 [494 16,495 10,496 30,497 74,498 23,499 64,500 100,501 83,502 65,503 16,504 37,505 28,506 3,507 62,508 24509 ],510 42511 ],512 "output": 1513 },514 {515 "input": [516 [517 33,518 13,519 59,520 42,521 84,522 16,523 86,524 43,525 50,526 65,527 73,528 10,529 73,530 99,531 65,532 11,533 3,534 61,535 90,536 22,537 47,538 22,539 98,540 22,541 8,542 44,543 21,544 45,545 52,546 39,547 59,548 31,549 20,550 47,551 19,552 19,553 7,554 46,555 80,556 2,557 44,558 100,559 32,560 86,561 6,562 12,563 78,564 46565 ],566 8567 ],568 "output": 2569 }570 ],571 "haskell_template": "countPairs :: [Int] -> Int -> Int\ncountPairs nums k ",572 "ocaml_template": "let countPairs (nums: int list) (k: int) : int = ",573 "scala_template": "def countPairs(nums: List[Int],k: Int): Int = { \n \n}",574 "java_template": "public static int countPairs(List<Integer> nums, int k) {\n\n}",575 "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 "576}