{"id":"3dc34409-c7f9-4ab9-b1b1-83a23f31a1d7","name":"Largest Number Possible After At Most K Swaps","description":"1. You are given a string which represents digits of a number.\r\n2. You have to create the maximum number by performing at-most k swap operations on its digits.\r\n\r\nNote -> Check out the question video and write the recursive code as it is intended without \r\n changing signature. The judge can't force you but intends you to teach a concept.","inputFormat":"A string S and a number K","outputFormat":"A number","constraints":"1 <= length of S <= 30\r\n1 <= K <= 10","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tstatic String max;\r\n\tpublic static void findMaximum(String str, int k) {\r\n\t\t//write your code here\r\n\t\t\r\n\t}\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString str = scn.next();\r\n\t\tint k = scn.nextInt();\r\n\t\t max = str;\r\n\t\tfindMaximum(str, k);\r\n\t\tSystem.out.println(max);\r\n\t}\r\n\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"1234567\r\n4","sampleOutput":"7654321","questionVideo":"https://www.youtube.com/embed/5crucASFoA4?end=195","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"082986ae-d618-4a59-9ab3-6d79056679a4","name":"Recursion and Backtracking For Intermediate","slug":"recursion-and-backtracking-for-intermediate-330","type":0},{"id":"ed84c5f0-648e-469e-a8a9-1b8b6422f2d8","name":"Largest Number Possible After At Most K Swaps","slug":"largest-number-possible-after-at-most-k-swaps","type":1}],"next":{"id":"3139d7a9-db06-4d00-afd9-01d4eaeea162","name":"Largest number possible after at most k swaps MCQ","type":0,"slug":"largest-number-possible-after-at-most-k-swaps-mcq"},"prev":{"id":"57b72ce7-7ba7-4933-a138-3d5ce7660699","name":"Remove Invalid Parenthesis MCQ","type":0,"slug":"remove-invalid-parenthesis-mcq"}}}

Largest Number Possible After At Most K Swaps

1. You are given a string which represents digits of a number. 2. You have to create the maximum number by performing at-most k swap operations on its digits. Note -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't force you but intends you to teach a concept.

{"id":"3dc34409-c7f9-4ab9-b1b1-83a23f31a1d7","name":"Largest Number Possible After At Most K Swaps","description":"1. You are given a string which represents digits of a number.\r\n2. You have to create the maximum number by performing at-most k swap operations on its digits.\r\n\r\nNote -> Check out the question video and write the recursive code as it is intended without \r\n changing signature. The judge can't force you but intends you to teach a concept.","inputFormat":"A string S and a number K","outputFormat":"A number","constraints":"1 <= length of S <= 30\r\n1 <= K <= 10","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tstatic String max;\r\n\tpublic static void findMaximum(String str, int k) {\r\n\t\t//write your code here\r\n\t\t\r\n\t}\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString str = scn.next();\r\n\t\tint k = scn.nextInt();\r\n\t\t max = str;\r\n\t\tfindMaximum(str, k);\r\n\t\tSystem.out.println(max);\r\n\t}\r\n\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"1234567\r\n4","sampleOutput":"7654321","questionVideo":"https://www.youtube.com/embed/5crucASFoA4?end=195","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"082986ae-d618-4a59-9ab3-6d79056679a4","name":"Recursion and Backtracking For Intermediate","slug":"recursion-and-backtracking-for-intermediate-330","type":0},{"id":"ed84c5f0-648e-469e-a8a9-1b8b6422f2d8","name":"Largest Number Possible After At Most K Swaps","slug":"largest-number-possible-after-at-most-k-swaps","type":1}],"next":{"id":"3139d7a9-db06-4d00-afd9-01d4eaeea162","name":"Largest number possible after at most k swaps MCQ","type":0,"slug":"largest-number-possible-after-at-most-k-swaps-mcq"},"prev":{"id":"57b72ce7-7ba7-4933-a138-3d5ce7660699","name":"Remove Invalid Parenthesis MCQ","type":0,"slug":"remove-invalid-parenthesis-mcq"}}}
plane

Editor


Loading...

Largest Number Possible After At Most K Swaps

easy

1. You are given a string which represents digits of a number. 2. You have to create the maximum number by performing at-most k swap operations on its digits. Note -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't force you but intends you to teach a concept.

Constraints

1 <= length of S <= 30 1 <= K <= 10

Format

Input

A string S and a number K

Output

A number

Example

Sample Input

1234567 4

Sample Output

7654321

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode