Codebreaker
The Umbristan Department of Defense has urgently requested you to help them.
It has captured a series of codes that are all numbers that need to quickly be cracked.
The department has figured out the secret to the codes but needs your help in writing a computer program to quickly crack all the codes.
The department has figured out that the secret to each code which involves finding the largest prime number hidden inside each code.
If the code does not contain a prime number, simply output -1
instead.
Input
codes
: an array of integers representing all the code that need to be cracked
Output
an array consisting of all the cracked codes.
Examples
Example 1:
Input:
codes = `[12, 1, 2]`
Output: [2, -1, 2]
Explanation:
Constraints
1 <= codes.length <= 100000
1 <= codes[i] <= 100000