@Sairam i m 100 % sure about the correctness of the algo.i have proven it with test case.. Only way u can prove it wrong is to give a counter case not by intutive feeling.
if u find the diffence of count arrays for two indexes i and j then it indicates the count of the string starting from i and ending at j.Now whats wrong in that --
