java.lang.Object
g2701_2800.s2761_prime_pairs_with_target_sum.Solution

public class Solution extends Object
2761 - Prime Pairs With Target Sum.<p>Medium</p> <p>You are given an integer <code>n</code>. We say that two integers <code>x</code> and <code>y</code> form a prime number pair if:</p> <ul> <li><code>1 <= x <= y <= n</code></li> <li><code>x + y == n</code></li> <li><code>x</code> and <code>y</code> are prime numbers</li> </ul> <p>Return <em>the 2D sorted list of prime number pairs</em> <code>[x<sub>i</sub>, y<sub>i</sub>]</code>. The list should be sorted in <strong>increasing</strong> order of <code>x<sub>i</sub></code>. If there are no prime number pairs at all, return <em>an empty array</em>.</p> <p><strong>Note:</strong> A prime number is a natural number greater than <code>1</code> with only two factors, itself and <code>1</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> n = 10</p> <p><strong>Output:</strong> [[3,7],[5,5]]</p> <p><strong>Explanation:</strong></p> <p>In this example, there are two prime pairs that satisfy the criteria.</p> <p>These pairs are [3,7] and [5,5], and we return them in the sorted order as described in the problem statement.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> n = 2</p> <p><strong>Output:</strong> []</p> <p><strong>Explanation:</strong></p> <p>We can show that there is no prime number pair that gives a sum of 2, so we return an empty array.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= n <= 10<sup>6</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details