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: #include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define speed ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define endl '\n'
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int nxt[N][26];

signed main() {
	speed;
	string s;	cin >> s;
	int n = s.length();
	for(int i = 0; i < 26; i++)
		nxt[n][i] = n;
	for(int i = n-1; i >= 0; i--){
		for(int j = 0; j < 26; j++)
			nxt[i][j] = nxt[i+1][j];
		nxt[i][s[i]-'a'] = i;
	}
	stack<char> st;
	int cur = 0;
	string t = "";
	for(int i = 0; i < n; i++){
		while(nxt[i][cur] == n){
			cur++;
			if(cur == 26)
				break;
			while(!st.empty() && st.top()-'a' <= cur){
				t += st.top();
				st.pop();
			}
		}
		if(cur == 26){
			while(!st.empty() && st.top() <= s[i]){
				t += st.top();
				st.pop();
			}
			st.push(s[i]);
		}
		else{
			if(nxt[i][cur] == i)
				t += s[i];
			else
				st.push(s[i]);
		}
	}
	while(!st.empty()){
		t += st.top();
		st.pop();
	}
	cout << t;
	return 0;
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?