Explanation:The character 'l' appears most frequently, so it gets the shortest code '0'. The other characters get longer codes based on their frequencies.
Example 2:
Input:text = "aaaaabbc"
Output:{
"a": "0",
"b": "10",
"c": "11"
}
Explanation:The character 'a' appears most frequently and gets the shortest code '0'.
Example 3:
Input:text = "",
Output:{}
Explanation:Empty string will result in empty code map.