contains category wise problems(data structures, competitive) of popular platforms.
View the Project on GitHub mayankdutta/category-wise-problems
Tags: implementation constructive

i + 1 i will search till end of array, if i am able to find just greater element then i th.class Solution {
public:
void nextPermutation(vector<int>& arr) {
int n = arr.size();
int i = n - 2;
for (; i >= 0 && arr[i + 1] <= arr[i]; i--) { }
if (i < 0)
reverse(arr.begin(), arr.end());
else {
int j = i + 1;
int k = -1;
for (int j = i + 1; j < n; j++)
if (arr[i] < arr[j])
k = j;
if (k >= 0)
swap(arr[i], arr[k]);
reverse(arr.begin() + i + 1, arr.end());
}
}
};