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] variation of LIS problem

2014-03-12 Thread navneet singh gaur
It can be solved in O(nlogn). Just start from the end and find decreasing subsequence of size k. For example Eg arr[]={5,2,1,10,9,30,8,55}, start from the end and put the subsequence elements inside a different array. Following concept can be used effectively in the same manner but we have to