There is a standard library function for this


#1

Is this cheating?

string Solution::solve(string A) {
    if (next_permutation(A.begin(), A.end()))
        return A;
    else
        return "-1";
}