You are given an integer n. We say that two integers x and y form a prime number pair if:
1 <= x <= y <= n
x + y == n
x and y are prime numbers
Return the 2D sorted list of prime number pairs[xi, yi]. The list should be sorted in increasing order of xi. If there are no prime number pairs at all, return an empty array.
Note: A prime number is a natural number greater than 1 with only two factors, itself and 1.
classSolution: deffindPrimePairs(self, n: int) -> List[List[int]]: ret = [] is_primes = [True] * n primes = [] for i inrange(2, n): if is_primes[i]: primes.append(i) for p in primes: if p * i >= n: break is_primes[p * i] = False if i % p == 0: break for x in primes: if x > n/2: break y = n - x ifnot is_primes[y]: continue ret.append([x, y]) return ret