Find the Biggest number in HashSet/HashMap java

后端 未结 8 2113
我在风中等你
我在风中等你 2020-12-29 04:48

I would like to find the biggest number in HashSet and HashMap. Say I have the number [22,6763,32,42,33] in my HashSet and I want to find the largest number in my current Ha

8条回答
  •  孤城傲影
    2020-12-29 05:20

    In case of TreeMap, if you know the key/values are inserted randomly, the tree will be more or less balanced. Trees become unbalanced, if data is inserted in already sorted order, the capability to quickly find (or insert or delete) a given element is lost. In case of unbalanced tree, it will take time proportional to n, O(n) else O(1).

提交回复
热议问题