Given a number N, the task is to find a number in range from 1 to N such that its sum is maximum. If there are several such numbers, print the biggest of them.
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains a number N as input.
For each test case, print the biggest number having maximum sum in new line.
Input: n = 48 Output: 48 There are two numbers with maximum digit sum. The numbers are 48 and 39 Since 48 > 39, it is our answer.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.