Using ArrayList of ArrayList instead of array of Arraylists spends way more memory and is slightly slower (java)

Правка en1, от idk321, 2020-04-28 23:32:56

I was wondering now for sometime why my graph solutions usually take much more memory than fairly similar solutions in java. The thing is, I have avoided arrays of arraylist since arrays cant be assigned generics (if you use (ArrayList) array, some sites dont even accept your solution, but I have only know found out that you can just leave it without assigning this and it works just fine), but I have now finally tried using this, look at the result of two almost identical programs, only one has list of lists while the other has array of lists: (list of lists)-https://codeforces.net/contest/1324/submission/78422102 (array of lists)-https://codeforces.net/contest/1324/submission/78422518. Anyone knows why is this the case?

Теги #java, #listoflists, #graph, #arrayoflists

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский idk321 2020-04-28 23:32:56 853 Initial revision (published)