• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
May 07, 2024 |270 Views
SDE Sheet - Largest number possible
  Share   Like
Description
Discussion

This video is part of the Greedy section under GFG SDE Sheet.

In this problem, we are given a two numbers 'N' and 'S' , find the largest number that can be formed with 'N' digits and whose sum of digits should be equals to 'S'. Return -1 if it is not possible.

Example :

Input: N = 2, S = 9
Output: 90
Explanation: It is the biggest number with sum of digits equals to 9.

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-
Article: https://www.geeksforgeeks.org/find-the-largest-number-with-given-number-of-digits-and-sum-of-digits/
Problem: https://www.geeksforgeeks.org/problems/largest-number-possible5028/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/