Sort string based upon the count of characters Options

Posted by prp on Stack Overflow See other posts from Stack Overflow or by prp
Published on 2011-01-13T08:40:21Z Indexed on 2011/01/13 8:54 UTC
Read the original article Hit count: 208

Filed under:

Sample Data : input : "abcdacdc" Output : "cadb" here we have to sort strings in order of count of characters. If the count is same for characters. maintain the original order of the characters from input string.

my approach: i have used array of 26 for maintaining occurrence of all characters and sort it then print it.But while doing so i am not able to maintain order in case if two characters have same count.

please suggest any improvement or any other algo.

© Stack Overflow or respective owner

Related posts about algorithm