@ashish : couldnt get u.. can u give an example??
On Tue, May 22, 2012 at 5:45 PM, Prem Krishna Chettri hprem...@gmail.comwrote:
What I Could possibly think of is
For each string S1 that is an anagram of some string S, use Map and Store
the Key Value as (S1,S). Now there is a trick here abt
Write a method to sort an array of strings so that all the anagrams are
next to each other.
What i could think of is preparing a multi linked list( multimap) whereby
the key for each string is the sorted representation of the string(eg if
string is gac, its sorted representation is acg). Walk of
What I Could possibly think of is
For each string S1 that is an anagram of some string S, use Map and Store
the Key Value as (S1,S). Now there is a trick here abt how to reduce Time
Complexity here...
Now its easy to put all string which has correspondence S next to each
other. This is Simple
Anyways we need to sort all the words atleast once, one way is
To travel throught the list sorting each word and making a pair of the
orginal and the sorted word.
For Ex. If one of the original word in list is aanchal sorted is
aaachln. So store the pair aanchal, aaachln
Now sort this list of