The task is to find the smallest number with given sum of digits as S and number of digits as D.

Example 1:

Input:S = 9 D = 2Output:18Explanation:18 is the smallest numberpossible with sum = 9and total digits = 2.

Example 2:

Input:S = 20D = 3Output:299Explanation:299 is the smallest numberpossible with sum = 20and total digits = 3.

Your Task:

You don't need to read input or print anything. Your task is to complete the function smallestNumber() which takes the two integers S and D and returns a string which is the smallest number if possible, else return "-1".

Expected Time Complexity: O(D) Expected Auxiliary Space: O(1)