Next Permutation Problem
Next Permutation Problem — ExecCode Easy DSA Practice
Solve the Next Permutation problem on ExecCode. Free online easy DSA practice in Two Pointers. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, rearrange to the lowest possible order (sorted ascending).
Examples
Input nums = [1, 2, 3]; Output [1, 3, 2]. Input nums = [3, 2, 1]; Output [1, 2, 3]
Constraints
1 ≤ nums.length ≤ 100 0 ≤ nums[i] ≤ 100
Practice Next Permutation free on ExecCode. Browse DSA problems, topic map, and placement guides.