題庫
00:00

18. Next Permutation

中等陣列GoogleMicrosoft

Given an integer array nums, return its next lexicographically greater permutation.

Return the adjusted nums array for the current judge. The original LeetCode problem requires an in-place update.

範例 1:

輸入: nums = [1,2,3]
輸出: [1,3,2]

範例 2:

輸入: nums = [3,2,1]
輸出: [1,2,3]

限制條件:

  • 1 <= nums.length <= 100
核心程式碼模式
● 已自動儲存第 1 行,第 1 欄