Skip to content

Latest commit

 

History

History

0031.next-permutation

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

题目描述

实现获取下一个排列的函数,算法需要将给定数字序列重新排列成字典序中下一个更大的排列。

如果不存在下一个更大的排列,则将数字重新排列成最小的排列(即升序排列)。

必须原地修改,只允许使用额外常数空间。

以下是一些例子,输入位于左侧列,其相应输出位于右侧列。
1,2,31,3,2
3,2,11,2,3
1,1,51,5,1

解题思路

具体解法

Golang