Hello,
I am using an Array list in my code, but the ArrayList is not quit working for me.
Code:
ArrayList <ArrayList[]> Path = new ArrayList <ArrayList[]>();
to create an index, I do
Code:
paths.add(new ArrayList[2]);
paths.get(paths.size()-1)[0] = new ArrayList <Integer>();
paths.get(paths.size()-1)[1] = new ArrayList <Integer>();
What works very well. But I can not get the correct index deletion: If I have 10 index in the ArrayList path, for example, and I will keep only the last 5, I wrote:
Code:
for(i =0; i <5; i + +){
for(j =0j <ways.get(i)[0].size()j + +)
paths.get(i).remove(j);
}
and the AC did not work. If I write:
Code:
for(int g =0g <p g + +){
paths.get(g)[0].clear();
paths.get(g)[1].clear();
}
The AC works, but the top 5 indexes are always empty, but they still exist, although I wish that the last 5 indexes take up the first 5 and then pass the size to 5 index. Please help
Bookmarks