Algorithm · Salesforce · Medium
A lexicographically smaller permutation of an integer array is the arrangement that appears immediately before the current arrangement when all possible arrangements of its elements are sorted in dictionary order. You are given an array nums that may contain duplicate integers. Rearrange its elements so that nums becomes the previous permutation. If nums is already the smallest possible permutation (its elements are in nondecreasing order), rearrange it into the largest…
Checking your access…