You need to create more than 300000 ArrayList, filled with random numbers, and find the same among them. What is better to use: hashmap, arraylist, something else?

Upd. Arraylist of the form {a, b, c}: abc are random. And these> 300,000. Compare "on the fly" every new with existing ones.

  • array is not suitable? - michael_best
  • one
    stand, you completely changed the task - michael_best
  • That's why I updated the question that I saw: it is not accurate. - sapeg

1 answer 1

ArrayList will suit you. To find a suitable structure, you can use the following image:

enter image description here wd wd

And if the amount of data in the list is known in advance, then a regular array will do. Because it is faster than ArrayList

PS You have changed the question. ArrayList or array is best suited anyway. You can sort the array using the Arrays.sort method and compare Arrays.equals with each other.

  • In fact, I will need to compare the collection with the arraylist. Because each new value needs to be added to a collection for storage. - sapeg