Question: Digits swap Time limit: 1 2 5 0 ms Memory limit: 2 5 6 MB You are given an integer N and another integer K
Digits swap
Time limit: ms
Memory limit: MB
You are given an integer and another integer You are allowed to perform at most operations of the type:
Pick two arbitrary digits and swap them.
After each swap, the number must not contain any leading zeroes. Your task is to maximize the value of after the swaps.
Standard Input
The first line contains two integers and
Standard Output
Output one integer the largest possible value of after performing at most swaps.
Constraints and Notes
Swapping two digits should not result in a number with leading zeroes.
tableInputOutput
Explanation
We will perform the following sequence of swaps:
into
into
into
The console should be able to give any input it wants
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
