[InterviewBit] Next Similar Number

Next Similar Number

  • Time :
  • Space :
1
2
3
4
5
6
string Solution::solve(string A) {
string res = A;
next_permutation(begin(res), end(res));
return res > A ? res : "-1";
}

Author: Song Hayoung
Link: https://songhayoung.github.io/2022/10/31/PS/interviewbit/next-similar-number/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.