For this Question: Given a string S and an integer K, your task is to find the lexicographically maximum string after performing at most K swaps.The first line of input contains a single string S. The next line of input contains the value of K.

Constraints:-
1 <= |S| <= 9
S contains digits from 1 to 9
1 <= K <= 4Print the lexicographically maximum string after performing at most K swaps.Sample Input:-
132
2

Sample Output:-
321

Sample Input:-
254
1

Sample Output:-
524, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
    public static String maxString;

    public static void solve(char charArr[], int swaps, int len, int index) {
        if(swaps == 0 || index == len) {
            return;
        }
        char maxChar = charArr[index];

        for(int i = index; i < len; i++) {

            if(charArr[i] > maxChar) {
                maxChar = charArr[i];
            }
        }


        if(maxChar != charArr[index]) {

            swaps--;
        }

        for(int i = len - 1; i >= index; i--) {
            if(charArr[i] == maxChar) {





                charArr = swap(charArr, i, index);
                String str = new String(charArr);

                if(Integer.parseInt(maxString) < Integer.parseInt(str)) {

                    maxString = str;
                }
                solve(charArr, swaps, len, index + 1);
                charArr = swap(charArr, i, index);
            }
        }
    }

    public static char[] swap(char charArr[], int i, int j) {

        char temp = charArr[i];
        charArr[i] = charArr[j];
        charArr[j] = temp;
        return charArr;
    }


    public static void main (String[] args) {
        Scanner sc = new Scanner (System.in);
        String str = sc.next();
        int swaps = sc.nextInt();
        char charArr[] = str.toCharArray();
        maxString = str;
        solve(charArr, swaps, charArr.length, 0);
        System.out.println(maxString);
    }


}, In this Programming Language: Java, Now tell me if this Code is compilable or not?