1053. Previous Permutation With One Swap
https://leetcode.com/problems/previous-permutation-with-one-swap
Description
Given an array of positive integers arr
(not necessarily distinct), return the lexicographically largest permutation that is smaller than arr
, that can be made with exactly one swap (A swap exchanges the positions of two numbers arr[i]
and arr[j]
). If it cannot be done, then return the same array.
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
1 <= arr.length <= 104
1 <= arr[i] <= 104
ac
Last updated