• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
September 14, 2023 |2.0K Views
PROBLEM OF THE DAY: 13/09/2023 | Largest number possible
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. 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 Number Theory but will also help you build up problem-solving skills.

In this video, we are given 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

Explaination: It is the biggest number with sum of digits equals to 9.
 

Give the problem a try before going through the video. All the best!!!

Problem Link: https://practice.geeksforgeeks.org/problems/largest-number-possible5028/1

Solution Function Link: https://ide.geeksforgeeks.org/online-cpp-compiler/50f96866-a016-4b2f-b8bb-eaa7c60a3fa7