question=https://hack.codingblocks.com/contests/c/424/1399
answer=https://ide.codingblocks.com/#/s/15232
the final answer is right but it shows wrong answer
question=https://hack.codingblocks.com/contests/c/424/1399
answer=https://ide.codingblocks.com/#/s/15232
the final answer is right but it shows wrong answer
Aayush for the input 4 aabbccdddd u are having wrong output try to do it with recursion
for every frequency take down its – while k exist and return there minimum
if u have any futher problem i will post my code
Hii Aayush ! , actually ur code is not working for this case
3
1 abccccdddddd
0 cdkac
0 bghkab
U should check in bubble function And one more thing as you can see that you need a data structure which sort the whole array at every iteration for decrementing input integer , so it will be better choice to use priority queue 
if you still face difficulty then you can go through this
https://ide.codingblocks.com/#/s/16134
what should be the output?
Output should be
43
7
8
But your code is giving this
43
5
6
Hope you are getting this 
i asked to phantom not you.
for that output i sorted the initial input and then got the expected answer.
anyway thanx