2 lines solution in C++


#1

next permutation returns false if the string is the highest permutation of itself

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

#2

A 1 line solution… happy…!?!

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