A Lucky number is the largest number made up of only digits 2,3 and 5 such that the count for each digit is divisible by the number obtained by multiplication of remaining two digits. You are provided with the number N and you have to output the lucky number of N digits. If no lucky number exists for the given N output -1.
Input:N = 4Output:
-1Explanation:There isn't any 4 digit Lucky Number.
Input:N = 16Output:
5555553333333333Explanation:There are six '5' and ten '3' in the
number. And also, 2*3=6 and 2*5=10.
There is no 16 digit number greater
which satisfies the conditions.
You don't need to read input or print anything. Your task is to complete the function getLuckyNum() which takes an Integer N as input and returns the answer as a String.
Expected Time Complexity: O(N3) Expected Auxiliary Space: O(1)