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

Revision en1, by 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://mirror.codeforces.com/contest/1324/submission/78422102 (array of lists)-https://mirror.codeforces.com/contest/1324/submission/78422518. Anyone knows why is this the case?

Tags #java, #listoflists, #graph, #arrayoflists

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English idk321 2020-04-28 23:32:56 853 Initial revision (published)