1.题目
list唯一化
2.数据结构与算法
algorithm:先排序,再使用双指针进行唯一化
3.源代码
#include "stdafx.h"
#include <iostream>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <algorithm>
using namespace std;
void unique(list<int> &l){
list<int>::iterator q = l.begin();
list<int>::iterator p;
for (p = q++; p!=l.end();){
if

本文探讨了如何实现列表唯一化,包括通过排序和双指针的方法。无序列表唯一化的时间复杂度为ο(nlogn),而有序列表的时间复杂度为ο(n)。文中引用了邓俊辉的《数据结构(C++语言版)》作为参考。
最低0.47元/天 解锁文章
8万+

被折叠的 条评论
为什么被折叠?



