Page 1 of 1

Anagram

Posted: Mon Oct 03, 2005 1:02 pm
by Tanu
My friend named Pinky...
I can called her....
KINPY,NIPKY,KINPY,PIKNY...
By keeping vowel in the right position
Hi anyone help me to learn about Anagram...
I failed to solve anagram problems.....
PLZ help...

Posted: Thu Oct 13, 2005 12:18 pm
by Fixxxer
try STL next_permutation

Posted: Sat Oct 15, 2005 12:16 pm
by kenneth
If you want to check if two words s1, s2 are anagrams,

perform sorting on both s1 and s2 in term of the characters. If the result of both strings are the same, then they are anagrams =)

Sorry

Posted: Sun Oct 16, 2005 3:12 pm
by Tanu
Sorry i'm failed again...
I wanna make permutation of a given string....
Example "Killer"....
I wanna know the algorithm of permute under a rule...
Think like that keeping l in the outer side...
or some thing like keeping r only in odd position...
Plz help...

Posted: Thu Nov 03, 2005 3:39 pm
by kenneth
Tanu, like Fixxxer said, next_permutation will do your trick. However, it may be a bit slow depending on what you need to do.

Furthermore, should you be trying to solve an ACM problem, it would be helpful to tell us the problem number so that we can look at the spec.

About my trouble

Posted: Sat Nov 05, 2005 9:13 am
by Tanu
Kenneth,Hi
I'm talking about any problems abt anagram in acm...
Let 146 I have take the way ->
1. first i find i scan the given string from left to right to find the rightmost charecter(nth char) that has its sussessor(in mth pos).. Its works okey.
2. Next is swapping it with with its sussessor(nth with mth).
3. nest swap from n+1 to stringlength(using bubble sort).

Example:
"asssdfrcab"
step 1: 'f' has sussesor 'r'
step 2: swap ->asssdrfcab
step 3: sort ->asssrabcf
Its currect but may not work in many ways ...
can you say why?
another 195 made sol by back tracking got ole...
plz help
Thanks

late

Posted: Sat Nov 05, 2005 9:14 am
by Tanu
net is not available frequently so may late(sorry)

Posted: Sun Nov 13, 2005 5:26 pm
by tuman
tanvir_cuet,
Yes u r right :lol: :D :) :( :o :-? 8) :lol: :x :evil: :cry: :oops: :P :roll: :wink:

thanks a lot tanu......