collection.Counter("bcdefffaa")
Run Code Online (Sandbox Code Playgroud)
返回输出:
Counter({'f': 3, 'a': 2, 'c': 1, 'b': 1, 'e': 1, 'd': 1})
Run Code Online (Sandbox Code Playgroud)
由于该结果是在值下降的排序顺序,这是否意味着建设计数器是成本O(nlogn),而不是O(n)?
还有,Java中的collections.Counter相当于什么?