• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
July 16, 2024 |440 Views

PROBLEM OF THE DAY : 15/07/2024 | Smallest Number

Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Jay Dalsaniya We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Greedy but also build up problem-solving skills.

Given two integers s and d. The task is to find the smallest number such that the sum of its digits is s and the number of digits in the number are d. Return a string that is the smallest possible number. If it is not possible then return -1.

Examples:

Input: s = 9, d = 2
Output: 18 
Explanation: 18 is the smallest number possible with the sum of digits = 9 and total digits = 2.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/smallest-number5829/1