Digital dictionary

There is a question on hackerblock, can u pls check my code

hey @Tushar-Goel-1587999611286693 are you sure you attached the correct code for pythagoras triplets?

I didn’t know how to ask the questions which are not in the course, so I asked here

in that case please provide the link of the question as well.

https://hack.codingblocks.com/app/dcb/749

https://ide.codingblocks.com/s/199083 I would come back to that question a little later, can u pls tell why is my this code not working for the above question

Could you please explain your approach as your code is pretty complex for an easy problem.
Meanwhile this is a working code which uses priority queue https://ide.codingblocks.com/s/199219

thanks for the code, in my approach I created a class doit which is a pair of the each character and it’s frequency, and a vector to store it, sorted the vector based on the most frequency to least frequency, then got the frequency of first element (highest frequency number), just one less than its next element, sorted the vector again and repeated the process unless the input k becomes 0, them took the sum of the squares of all the numbers.

https://hack.codingblocks.com/app/dcb/1088 THis is the other question, my code is failing in https://ide.codingblocks.com/s/197544

hey @Tushar-Goel-1587999611286693 in your implementation if a same character was to appear again but at different location produces wrong answer for example in case of
1
3 aabbaa
answer should be 5 but your answer is 3.
Please ask new question, in new doubt as that way it’ll be easier to track that doubt moreover it’ll keep the conversation in thread limited to one topic and you can get faster reply that way :slight_smile:

Makes sense, Thanks a lot for the help