2761. Prime Pairs With Target Sum Medium

@problem@discussion
#Array#Math#Enumeration#Number Theory



1/**
2 * [2761] Prime Pairs With Target Sum
3 *
4 * You are given an integer n. We say that two integers x and y form a prime number pair if:
5 * 
6 * 	1 <= x <= y <= n
7 * 	x + y == n
8 * 	x and y are prime numbers
9 * 
10 * 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.
11 * Note: A prime number is a natural number greater than 1 with only two factors, itself and 1.
12 *  
13 * <strong class="example">Example 1:
14 * 
15 * Input: n = 10
16 * Output: [[3,7],[5,5]]
17 * Explanation: In this example, there are two prime pairs that satisfy the criteria. 
18 * These pairs are [3,7] and [5,5], and we return them in the sorted order as described in the problem statement.
19 * 
20 * <strong class="example">Example 2:
21 * 
22 * Input: n = 2
23 * Output: []
24 * Explanation: We can show that there is no prime number pair that gives a sum of 2, so we return an empty array. 
25 * 
26 *  
27 * Constraints:
28 * 
29 * 	1 <= n <= 10^6
30 * 
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/prime-pairs-with-target-sum/
35// discuss: https://leetcode.com/problems/prime-pairs-with-target-sum/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40    pub fn find_prime_pairs(n: i32) -> Vec<Vec<i32>> {
41        vec![]
42    }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49    use super::*;
50
51    #[test]
52    fn test_2761() {
53    }
54}
55


Back
© 2025 bowen.ge All Rights Reserved.