Added Time Complexity and remove single comment into multi comment (#135)
* Added Time Complexity and remove single comment into multi comment * added new line at end of programpull/138/head
parent
4f8f068ecc
commit
616e931601
|
@ -14,7 +14,7 @@ int main()
|
||||||
s=(char*)malloc(sizeof(char)*1000);
|
s=(char*)malloc(sizeof(char)*1000);
|
||||||
// getting string
|
// getting string
|
||||||
fgets(s,1000,stdin);
|
fgets(s,1000,stdin);
|
||||||
// changing size to the length of string+1 to store null at end
|
// changing size to the length of string+1 to store null at end
|
||||||
s=realloc(s,strlen(s)+1);
|
s=realloc(s,strlen(s)+1);
|
||||||
//calling permutation
|
//calling permutation
|
||||||
permutation(s,0,strlen(s)-1);
|
permutation(s,0,strlen(s)-1);
|
||||||
|
@ -55,11 +55,14 @@ void swap(char *a,char *b)
|
||||||
*b=temp;
|
*b=temp;
|
||||||
//swapping done
|
//swapping done
|
||||||
}
|
}
|
||||||
// Example:
|
/* Example:
|
||||||
//Input: abc
|
Input: abc
|
||||||
//Output: 1(abc)
|
Output: 1(abc)
|
||||||
// 2(acb)
|
2(acb)
|
||||||
// 3(bac)
|
3(bac)
|
||||||
// 4(bca)
|
4(bca)
|
||||||
// 5(cba)
|
5(cba)
|
||||||
// 6(cab)
|
6(cab)
|
||||||
|
Time Complexity: O(n*n!)
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
Loading…
Reference in New Issue