For this Question: You are given a String S and two empty strings A and B. You are allowed to perform following two operations.
1. Remove an element from start of S and add it to the end of B.
2. Remove an element from end of B and add it to the end of A.

Find the lexicographical minimum string A that we can obtain using the above procedure.

Note: The final length of string A must be equal to initial length of string S.Input contains string S containing only lowercase alphabets.

Constraints
1 <= |S| <= 100000Print the lexicographical minimum string A that we can obtain.Input
cab

Output
abc

Input
acdb

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



class Main {
	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine().trim();
		int len = str.length();

		Stack<Integer> st = new Stack<Integer>();
		StringBuilder sb = new StringBuilder();

		int count[] = new int [26];
		for(int i=0;i<len;i++){
			count[str.charAt(i)-'a']++;
		}

		int j=0;
		for(int i=0;i<len;i++){
			while(count[j] == 0){
				j++;
			}
			while(!st.empty() && st.peek()  <= j){
				sb.append((char)	(st.pop() + 'a') );
			}

			st.push(str.charAt(i) - 'a');
			count[str.charAt(i)-'a']--;




		}
		while(!st.empty()){
			sb.append((char)	(st.pop() + 'a') );
		}

		System.out.println(sb);

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