【发布时间】:2014-03-11 03:06:04
【问题描述】:
假设我有两个 HashMap 如下
HashMap<Character, Integer> map1 = new HashMap<Character, Integer>();
HashMap<Character, Integer> map2 = new HashMap<Character, Integer>();
现在我想将这两个合并在一起,并将它们作为 map3 放入另一个 HashMap
就渐近复杂性而言,最好的方法是什么。
【问题讨论】:
-
如果您担心性能,您可以使用
int[],前提是您可以对要计算的字母范围做出假设。这具有相同的时间复杂度,但速度要快很多倍。
标签: java performance asymptotic-complexity