Class Solution
java.lang.Object
g0001_0100.s0031_next_permutation.Solution
31 - Next Permutation.<p>Medium</p>
<p>Implement <strong>next permutation</strong> , which rearranges numbers into the lexicographically next greater permutation of numbers.</p>
<p>If such an arrangement is not possible, it must rearrange it as the lowest possible order (i.e., sorted in ascending order).</p>
<p>The replacement must be <strong><a href="http://en.wikipedia.org/wiki/In-place_algorithm" target="_top">in place</a></strong> and use only constant extra memory.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [1,2,3]</p>
<p><strong>Output:</strong> [1,3,2]</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [3,2,1]</p>
<p><strong>Output:</strong> [1,2,3]</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> nums = [1,1,5]</p>
<p><strong>Output:</strong> [1,5,1]</p>
<p><strong>Example 4:</strong></p>
<p><strong>Input:</strong> nums = [1]</p>
<p><strong>Output:</strong> [1]</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= nums.length <= 100</code></li>
<li><code>0 <= nums[i] <= 100</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
nextPermutation
public void nextPermutation(int[] nums)
-