We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C
- Functions
- Permutations of Strings
- Discussions
Permutations of Strings
Permutations of Strings
Sort by
recency
|
132 Discussions
|
Please Login in order to post a comment
So here is the logic in plain English:
include
include
include
int next_permutation(int n, char **s) {
}
int next_permutation(int n, char **s) { for (int i=n-2; i>=0; i--) { if (strcmp(s[i], s[i+1]) < 0) { for (int j=n-1; j>i; j--) { if (strcmp(s[j], s[i]) > 0) { char *temp = s[i]; s[i] = s[j]; s[j] = temp;
}
Here is my solution: