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.
I have done the program in the following manner but this program does not execute all test cases.
void swap(char s, int p, int q) {
char temp=s[p];
s[p] = s[q];
s[q] = temp;
}
void reverseWords(char s, int a, int z){
while(a
* Complete this method
* Return 0 when there is no next permutation and 1 otherwise
* Modify array s to its next permutation
*/
for(int i=0;i
return 0;
}
the above program satisfies 0 to 7 test cases.
8 to 42 test cases does not satisfies.
please provide the correct solution.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Permutations of Strings
You are viewing a single comment's thread. Return to all comments →
I have done the program in the following manner but this program does not execute all test cases. void swap(char s, int p, int q) { char temp=s[p]; s[p] = s[q]; s[q] = temp; } void reverseWords(char s, int a, int z){ while(a
* Complete this method * Return 0 when there is no next permutation and 1 otherwise * Modify array s to its next permutation */ for(int i=0;i return 0; }
the above program satisfies 0 to 7 test cases. 8 to 42 test cases does not satisfies. please provide the correct solution.