Hi Nishanth Pandey,
I got it. If str[end] char is present in
any index between [start, end) we would have already generated
permutations with str[end] character in index start. So no need to
generate those permutations again.
Again, Thank you very much for your
Hi Nishanth Pandey,
Excellent solution! It meets all
requirements in problem!
One thing I am finding hard to understand is your duplicate functions logic.
code is simple. But reason behind it I am finding hard.
I would write it like
bool duplicate(char str[], i
use C++, next_permutation, in
2014/1/7 Nishant Pandey
> This will help u i guess :
>
> #include
> #include
> using namespace std;
>
> void swap(char str[],int m,int n ) {
> char temp=str[m];
> str[m]=str[n];
> str[n]=temp;
> }
> bool duplicate(char str[], int start, int end)
> { if(start
This will help u i guess :
#include
#include
using namespace std;
void swap(char str[],int m,int n ) {
char temp=str[m];
str[m]=str[n];
str[n]=temp;
}
bool duplicate(char str[], int start, int end)
{ if(start == end)
return false;
else
for(; start= end){
cout< wrote:
>
This u can do it using the backtracking method. To know how to use
backtracking refer algorithm design manual by steve skiena.
On 7 January 2014 03:35, bujji jajala wrote:
> generate all possible DISTINCT permutations of a given string with some
> possible repeated characters. Use as minimal me