you are given an nested array list such as : list = [[-1,2,1],[-2,-2,4],[-1,2,-1],[-1,-2,3],[-1,2,-1]]
i want to have an output like this : [[-1,2,1],[-2,-2,4],[-1,-2,3]]
but its not likely to come with the code i am using...
for(int i=0;i<list.size();i++){
for(int j=i+1;j<list.size();j++){
if(list.get(i).eqauls(list.get(j)))
{
list.remove(list.get(j));
}
}
}
System.out.println(list);
i have done like this but its not taking and duplicates are still there so i have done in another way something like this...
List<List<Integer>> list2= new ArrayList<List<Integer>>();
for(int i=0;i<list.size();i++){
for(int j=i+1;j<list.size();j++){
if(!list.get(i).eqauls(list.get(j)))
{
List<Integer> p= new ArrayList<Integer>();
for(int m=0;m<list.size();m++){
for(int n=0;n<list.get(i).size();n++){
p.add(list.get(i).get(m));
list2.add(p);
}
}
}
System.out.println(list2);
Output: Run time error What should i do in this case....only using array list data structures only...