Trying to get lowest integers

前端 未结 3 463
广开言路
广开言路 2021-01-29 11:53

So I have 4 list, I want to find out which list.size(); is the lowest. I can find the lowest but some turn out to be the same, this is what I have.

                      


        
3条回答
  •  北荒
    北荒 (楼主)
    2021-01-29 12:46

    Here's how I'd approach your requirements:

    1. Define a Multimap which would store list.size values and map it to the Set of labels (or lists, depeding what you're interested in - not 100% clear from the question). So in your case multimap will store the following:

      2 -> Set("Diamond", "Emerald")
      3 -> Set("Gold")
      4 -> Set("Iron")

    2. Find lowest value of all multimap keys.

    3. Get the set of labels for the lowest value.

    4. Choose one of the labels at random.

提交回复
热议问题