时间复杂度位为O(n^2)
//删除重复值
bool Del_r(SqList &L) {
int y = 1, flag = 0;
for (int i = 1; i < L.length; i++) {
for (int j = 0; j <= i - 1; j++) {
if (L.data[i] == L.data[j]) {
flag = 1;
break;
}
}
if (flag == 0) {
L.data[y] = L.data[i];
y++;
}
flag = 0;
}
L.length = y;
return true;
}
如果想要更高效,可采用hash。
标签:删除,int,元素,无序,重复,表中 From: https://www.cnblogs.com/mcyn/p/17028819.html