Next Similar Number Time : Space : 123456string Solution::solve(string A) { string res = A; next_permutation(begin(res), end(res)); return res > A ? res : "-1";}