TheRealSamuel/LeetCodeProblem
0572
1{2 "id": 2610,3 "name": "closest_prime_numbers_in_range",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/closest-prime-numbers-in-range/",6 "date": "1671926400000",7 "task_description": "Given two positive integers `left` and `right`, find the two integers `num1` and `num2` such that: `left <= num1 < num2 <= right `. Both `num1` and `num2` are prime numbers. `num2 - num1` is the **minimum** amongst all other pairs satisfying the above conditions. Return the positive integer array `ans = [num1, num2]`. If there are multiple pairs satisfying these conditions, return the one with the **smallest** `num1` value. If no such numbers exist, return `[-1, -1]`_._ **Example 1:** ``` **Input:** left = 10, right = 19 **Output:** [11,13] **Explanation:** The prime numbers between 10 and 19 are 11, 13, 17, and 19. The closest gap between any pair is 2, which can be achieved by [11,13] or [17,19]. Since 11 is smaller than 17, we return the first pair. ``` **Example 2:** ``` **Input:** left = 4, right = 6 **Output:** [-1,-1] **Explanation:** There exists only one prime number in the given range, so the conditions cannot be satisfied. ``` **Constraints:** `1 <= left <= right <= 106`",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "left = 10, right = 19",12 "output": "[11,13] "13 },14 {15 "label": "Example 2",16 "input": "left = 4, right = 6",17 "output": "[-1,-1] "18 }19 ],20 "private_test_cases": [21 {22 "input": [23 259000,24 60476125 ],26 "output": [27 259121,28 25912329 ]30 },31 {32 "input": [33 957158,34 97235935 ],36 "output": [37 957431,38 95743339 ]40 },41 {42 "input": [43 55246,44 76357145 ],46 "output": [47 55331,48 5533349 ]50 },51 {52 "input": [53 649910,54 68639855 ],56 "output": [57 650327,58 65032959 ]60 },61 {62 "input": [63 331636,64 93890465 ],66 "output": [67 331691,68 33169369 ]70 },71 {72 "input": [73 725612,74 91260875 ],76 "output": [77 725861,78 72586379 ]80 },81 {82 "input": [83 124471,84 28119785 ],86 "output": [87 124541,88 12454389 ]90 },91 {92 "input": [93 523427,94 66366395 ],96 "output": [97 523487,98 52348999 ]100 },101 {102 "input": [103 863522,104 999759105 ],106 "output": [107 863537,108 863539109 ]110 },111 {112 "input": [113 508948,114 963261115 ],116 "output": [117 509147,118 509149119 ]120 }121 ],122 "haskell_template": "closestPrimes :: Int -> Int -> [Int]\nclosestPrimes left right ",123 "ocaml_template": "let closestPrimes (left: int) (right: int) : int list = ",124 "scala_template": "def closestPrimes(left: Int,right: Int): List[Int] = { \n \n}",125 "java_template": "public static List<Integer> closestPrimes(int left, int right) {\n\n}",126 "python_template": "class Solution(object):\n def closestPrimes(self, left, right):\n \"\"\"\n :type left: int\n :type right: int\n :rtype: List[int]\n \"\"\"\n "127}