C++ 2 lines code


#1

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


#2

Thanks man! Loved your approach


#3

A 1 line solution… happy.…!?!

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

#4

Brother How next_permutation compare , that is first is smaller and second is larger in If loop
means bro How If loop work