Re: [algogeeks] Re: DISTINCT Permutations ( Not Easy)

2014-03-12 Thread navneet singh gaur
void permute(char *a, int i, int n) { int j; if (i == n) printf(%s\n, a); for (j = i; j = n; j++) { if(a[i] != a[j]) { swap(a[i], a[j]); //just check before swapping if you are swapping different elements //or

Re: [algogeeks] Re: DISTINCT Permutations ( Not Easy)

2014-03-12 Thread navneet singh gaur
formatting changes . void permute(char *a, int i, int n) { int j; if (i == n) printf(%s\n, a); for (j = i; j = n; j++) { if(a[i] != a[j]) check before swapping if you are swapping different elements or not, if not then don't. { swap(a[i], a[j]);

Re: [algogeeks] Re: DISTINCT Permutations ( Not Easy)

2014-01-11 Thread bujji jajala
Hi Don, Good one :) Nice to see different approaches for this problem. -Thanks, Bujji On Fri, Jan 10, 2014 at 9:11 AM, Don dondod...@gmail.com wrote: Sort the input string and remove duplicates, keeping a count of the number of occurrences of each character. They you can build

[algogeeks] Re: DISTINCT Permutations ( Not Easy)

2014-01-10 Thread Don
Sort the input string and remove duplicates, keeping a count of the number of occurrences of each character. They you can build the permutations easily. For your example, you would start with char *str = aba; int len = strlen(str); Which would be converted to char *str ab; int rep[N] =