Gyh's Braindump

31. Next Permutation

tags
trick
source
leetcode

Solution

Complexity

  • time: O(n), worst case, scan two times of the array
  • space: O(1)