贪心模板 Ian 2023-02-05 约 63 字 预计阅读 1 分钟 次阅读 目录 下一个排列 下一个排列 1 2 3 4 5 6 7 8 9 10 11 12 13 def nxt(A): n = len(A) i = n-2 while i >= 0 and A[i] >= A[i+1]: i -= 1 if i < 0: return [] j = n-1 while A[j] <= A[i]: j -= 1 A[i], A[j] = A[j], A[i] A[i+1:] = A[i+1:][::-1] return A Please enable JavaScript to view the comments powered by Valine.