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
實現思路是: