Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

/leet/ challenge #1: permutation sequence

Name: Anonymous 2021-03-21 19:34

Implement
next permutation
, which rearranges numbers (nums) into the lexicographically next greater permutation of numbers.
If such an arrangement is not possible, it must rearrange it as the lowest possible order (i.e., sorted in ascending order).
The replacement must be in place and use only constant extra memory.

Example 1:
Input:[1,2,3]
Output: [1,3,2]

Example 2:
Input: [3,2,1]
Output: [1,2,3]

Example 3:
Input: [1,1,5]
Output: [1,5,1]

Example 4:
Input: [1]
Output: [1]

Constraints:
1 <= nums.length <= 10e6
0 <= nums[i] <= 2147483647



Shortest code wins bonus prize, but the main prize goes to every post with actually functioning code.

The deadline is 691200 seconds from this post's timestamp.

Name: Anonymous 2021-03-22 19:35

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(int argc,char**argv){
vector<string> arguments(argv + 1, argv + argc);
next_permutation(begin(arguments),end(arguments));
for(size_t i;i<arguments.size();i++)cout<<arguments[i];
;return 0;}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List