Lucky Number-2
Basic Accuracy: 0.0% Submissions: 0 Points: 1

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.

Example 1:

Input:
N = 4
Output:
-1
Explanation:
There isn't any 4 digit Lucky Number.

Example 2:

Input:
N = 16
Output:
5555553333333333 
Explanation:
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.

Your Task:
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)

Constraints:
1 <= N <= 103

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.