You are given two integers n and s.
Consider all prime numbers less than or equal to n. Select some of these primes such that:
s.Return an integer array containing the selected primes in increasing order. If multiple optimal selections exist, return any of them.
If no prime can be selected, 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 = 15
Output: [3,5,7]
Explanation:
n = 15 are 2, 3, 5, 7, 11, and 13.[3, 5, 7], whose sum is 3 + 5 + 7 = 15.2 + 3 + 5 + 7 = 17, which exceeds s = 15. Therefore, selecting four or more primes is impossible, and the maximum number of selected primes is three.[3, 5, 7] is one possible answer. Other valid answers include [2, 3, 5], [2, 3, 7], and [2, 5, 7].Example 3:
Input: n = 5, s = 1
Output: []
Explanation:
s = 1.Constraints:
1 <= n <= 1061 <= s <= 1097 20