Next Permutation

Given an integer array nums, modify it in place to produce its lexicographically next greater permutation.

If no greater permutation exists (i.e., the array is in descending order), rearrange i...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: