[Hacker Rank] Bigger is Greater

Bigger is Greater

  • Time : O(1)
  • Space : O(1)
1
2
3
4
5
string biggerIsGreater(string w) {
string res = w;
next_permutation(begin(res), end(res));
return res > w ? res : "no answer";
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2022/06/06/PS/HackerRank/bigger-is-greater/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.