educative.io

Does the order matters in correct solution?

While the solution mention


But the programs gives

Is order a requirement?

The only requirement of the algorithm is that the characters are in decreasing order of their frequency. So, if more than one characters have the same frequency, they can be in any order. This largely depends on the algorithm used to perform the task and isn’t a hardcore requirement of the solution.

1 Like