You are given two integers n and s.
Consider all prime numbers less than or equal to n. Select a subset of these primes such that:
s.Return an integer array containing the selected primes in increasing order. If no valid non-empty subset exists, return an empty array.
Example 1:
Input: n = 7, s = 20
Output: [2, 3, 5, 7]
Explanation:
n = 7 are 2, 3, 5, and 7.2 + 3 + 5 + 7 = 17, which is less than or equal to s = 20.[2, 3, 5, 7].Example 2:
Input: n = 15, s = 18
Output: [5,13]
Explanation:
[5, 13], [7, 11], [2, 3, 13], and [2, 5, 11]. Since this sum equals s, it is the maximum possible sum.[5, 13] and [7, 11] contain the fewest primes: two.[5, 13] is lexicographically smaller because its first element, 5, is smaller than 7. Thus, the answer is [5, 13].Example 3:
Input: n = 5, s = 1
Output: []
Explanation:
s = 1.Constraints:
1 <= n <= 10001 <= s <= 10007 20