实现足够大List<int>剔除重复的数字
来源:互联网 发布:软件定义 编辑:程序博客网 时间:2024/05/22 12:27
static void Screen() { List<int> newList=new List<int>(); List<int> list =new List<int>(); for (int i = 1; i < 100000; i++) { list.Add(i%100); } int repetition = 0; DateTime ts = System.DateTime.Now; list.Sort(); int max = list.Count; int _temp = list[0]; for (int i = 1; i < max; i++) { if (_temp.Equals(list[i])) { repetition++; continue; } newList.Add(_temp); _temp = list[i]; } //添加最后一条 newList.Add(_temp); TimeSpan tSpan = System.DateTime.Now - ts; Debug.Log("消耗时间:"+tSpan.Milliseconds); Debug.Log("重复:"+repetition); Debug.Log("正确个数:"+newList.Count); }
消耗时间:90
重复:99899
正确个数:100
实现思路是:
1. 先对这个数据排序。
2. 对比前后两条数据,相同的调过,不同的保留下来
0 0
- 实现足够大List<int>剔除重复的数字
- 剔除List里的重复值
- 剔除List 里重复值的问题
- 剔除List中的重复值
- 剔除List中的重复值
- 剔除List中的重复值
- Set剔除重复数据和List的排序问题
- 需要足够大的类
- 循环剔除集合(List)中的重复元素
- 乱序查找int数组中重复的数字
- 统计int数组中重复数字的个数
- 字符串剔除不相邻的重复字符
- 实现给定一个字符串剔除重复字符,并统计各个字符出现的次数
- C实现 显示重复的数字
- 数组中重复的数字java实现
- 【ORACLE/SQLSERVER/MySQL】重复行剔除需求实现
- list集合去除重复对象的实现
- 寻找第k大或第k小的算法 -- 内存足够(C++实现)
- Spark Utils find localIpAddress
- java 数据结构
- C#中文本文件与二进制文件
- 51nod_1046 A^B Mod C
- 数据库同步
- 实现足够大List<int>剔除重复的数字
- can’t refactor code used in this language
- MySQL存储过程decimal得到值为0.00问题
- What exactly is copy-on-modify semantics in R, and where is the canonical source?
- 表格内容筛选
- 2017gmic大会|倒计时3天(文末有彩蛋)
- 大型网站技术架构-网站高性能架构-记录
- windows调用另外一个EXE程序,WinExec+Cmd+BAT
- JSP页面,脚本标签