This can be solve by considering following case: i) If all the letters in the word are distinct : Just concatenate, reverse of the string(excluding last letter) to the original word..e.g. ZXKH==>>ZXKH KXZ
ii)If two letters are same in the word : First ignore all the letters between those same words , and make left sub-string and right sub-string of those *same letters* equal by adding letters.. e.g rzLkhmLty===>> rzyt LkhmLtyzr And then apply rule i) for middle letters. e.g. rzytLkhmLtyzr ===>> rzytLkhmhkLtyzr iii)If there are more than a *set of same letters* then first consider the farthest set and make it palindrome using rule ii) , e.g. ilOtPuyPuOer===>>ilreOtPuyPuOerli and move to next pair of same letters i.e. P,P..(use recursion) and ignore last modified position of same letters i.e. O,O and again apply rule ii) e.g. ilreOtPuyPuOerli===>>>ilreOtuPuyPutOerli And then finally use rule no i) for distinct words..e.g.ilreOtuPuyPutOerli===>>ilreOtuPuyuPutOerli On Sunday, 4 September 2011 19:54:35 UTC+5:30, learner wrote: > > Given a word, convert it into a palindrome with minimum addition of > letters to it. letters can be added anywhere in the word. for eg if > yahoo is given result shud be yahohay. > > > Thanks > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/Hsd6Tohi95oJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.