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:

  1. Anonymous9:09 AM

    to whom this message is directed at ....

    ReplyDelete
  2. No one in particular. Maybe myself :)

    ReplyDelete
  3. Anonymous9:24 AM

    Counter Retort :D

    ReplyDelete