The survey of permutations of finite sets is an important subject in the fields of combinatorics and group theory. In elementary combinatorics, the K-permutations, or partial permutations, are the ordered agreements of K distinct components choose from a set. Stedman widens the consideration of permutations; he goes on to consider the number of permutations of the letters of the alphabet and of horses from a stable of 20.A first case in which apparently unrelated mathematical questions were study with the help of permutations happened around 1770, when Joseph Louis Lagrange, in the survey of polynomial equations, detected that property of the permutations of the beginnings of an equation are associated to the possibility to solve it. Fabian Stedman in 1677 described factorials when explaining the number of permutations of Bell in change ringing. The rule to determine the number of permutations of n objects was known in Indian culture around 1150.

COMING SOON!

```
class Solution {
public:
void nextPermutation(vector<int> &num) {
int i = num.size() - 1;
while (i >= 1 && num[i-1] >= num[i]) {
i--;
}
if (i == 0) {
reverse(num.begin(), num.end());
return;
}
for (int j = num.size() - 1; j >= i; j--) {
if (num[j] > num[i-1]) {
swap(num[j], num[i-1]);
break;
}
}
reverse(num.begin() + i, num.end());
}
};
```