Sujan Sir's Magical Number
Time: 1 s
Memory: 125 MB
Memory: 125 MB
In Batch-15, Professor Dr. Sujan Ali is famous for giving strange and tricky assignments during coding classes.
One day, he handed out a “magical number” challenge:
“Here’s a number N. Delete exactly K digits from it to get the largest number possible. And yes, don’t create a number with leading zeroes, or it’s zero points for everyone!”
The students stared at their screens. Some tried random deletions, some panicked. The real winners are those who can think strategically, because the largest number isn’t always obvious.
Now it’s your turn. Can you maximize the magical number by carefully removing exactly K digits and impress Professor Dr. Sujan Ali?
One day, he handed out a “magical number” challenge:
“Here’s a number N. Delete exactly K digits from it to get the largest number possible. And yes, don’t create a number with leading zeroes, or it’s zero points for everyone!”
The students stared at their screens. Some tried random deletions, some panicked. The real winners are those who can think strategically, because the largest number isn’t always obvious.
Now it’s your turn. Can you maximize the magical number by carefully removing exactly K digits and impress Professor Dr. Sujan Ali?
Input
The first line contains the integer N — the number to manipulate.The second line contains the integer K — the number of digits to remove.
Constraint
\(
1≤D≤10^5\) (D = number of digits in N)\(0≤K<D\)
Output
Print the largest number possible after deleting exactly K digits, with no leading zeroes.
Examples
| Input | Output |
|---|---|
|
44312
2 |
443
|
Problem Info
| Problem ID | 797 |
| Time Limit | 1000 ms |
| Memory Limit | 128000 KB |
| Moderators | Nabeel_Ahsan , tamjid_hossen , shazidmashrafi |
Statistics
Submit
You need to Login or Registration for submit your solution