# 是否有一种算法可以删除与另一个元素相同的某些元素？

##### 问题描述投票：-1回答：1

``````    boolean flg1 = true;
List<List<String>> tmp1 = new ArrayList <>();
List<List<String>> tmp2 = new ArrayList <>();
System.out.println();
System.out.println("Size of the subset: " + subset.size());
for(int i=0; i< subset.size();i++){
tmp1=subset.get(i);

// System.out.println("TMP1:"+ tmp1);

for(int j=0; j<subset.size();j++){
tmp2=subset.get(j);

// System.out.println("TMP2:"+ tmp2.get(1));

if(i != j && !compareOuterlist(tmp1,tmp2)){
flg1=true;
continue;
}
}
if(flg1){
count++;
System.out.println("TEST " + (i+1) + ":"+ tmp1);
}
}

System.out.println();
System.out.println("Total partition:"+ count);
}
public static boolean compareOuterlist(List<List<String>> p1, List<List<String>> p2){
if(p1.size() != p2.size()){
return false;
}
for(int i = 0;i < p1.size();i++){
if(!(compareInnerlist1(p1.get(i),p2.get(i)))){
return false;
}
}
return true;
}

public static boolean compareInnerlist1(List<String> p1, List<String> p2){
for(int i=0;i<p1.size();i++){
if(!(p1.equals(p2))){
return false;
}
}
return true;
}
``````

``````TEST 1:[[P11, X11, X22], [P11, X11, X22]]
TEST 2:[[P11, X11, X22], [P11, X11, X22]]
TEST 3:[[X11, X22], [P11, X22], [P11, X11]]
TEST 4:[[X11, X22], [P11, X22], [P11, X11]]
TEST 5:[[P11, X11, X22], [P11, X11, X22]]
TEST 6:[[P11, X11, X22], [P11, X11, X22]]
TEST 7:[[X11, X22], [P11, X22], [P11, X11]]
TEST 8:[[X11, X22], [P11, X22], [P11, X11]]
TEST 9:[[P11, X22], [X11, X22], [P11, X11]]
TEST 10:[[P11, X22], [X11, X22], [P11, X11]]
TEST 11:[[P11, X22], [X11, X22], [P11, X11]]
TEST 12:[[P11, X22], [X11, X22], [P11, X11]]
``````
java list algorithm
0

0