Monday, October 03, 2005

Permutation

Well, there was this sample google question on the notice board which went something like this: "How will you find whether string A is a permutation of string B?" . One method will be to actually make all the permutations and keep on comparing them with the other string. This is obviously inefficient as it takes O(N!) time. I did something else which takes O((N)^3) time (I think. I am not too good at analysis.). You just check whether all the characters in one string are there in the other string and their lengths are equal (obviously).

4 comments:

Anonymous said...

to whom this message is directed at ....

Rohit said...

No one in particular. Maybe myself :)

Anonymous said...

Counter Retort :D

Rohit said...

Yes exactly.