[unity C# 面试题]在1到100的整数数组上找到缺失的数字

Posted zsqdtz

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[unity C# 面试题]在1到100的整数数组上找到缺失的数字相关的知识,希望对你有一定的参考价值。

public void printMissingNumber(int[] numbers, int count)
{
int missingCount = count - numbers.Length;
int[] bitSet = new int[count];
for (int i = 0; i < numbers.Length; i++)
{
int number = numbers[i];
bitSet[number - 1] = number;
}
Debug.LogError("转换结束,要查找的个数为:"+ missingCount);
int length = bitSet.Length;
for (int i = 0; i < length; i++)
{
if (bitSet[i] == 0)
{
Debug.LogError(i+1);
}
}
}

以上是关于[unity C# 面试题]在1到100的整数数组上找到缺失的数字的主要内容,如果未能解决你的问题,请参考以下文章

Unity面试题精选

游戏开发指路Unity学习路线,三万字大纲(面试题大纲 | 知识图谱 | Unity游戏开发工程师)

微软谷歌百度等公司经典面试100题

Unity面试题精选

C#经典面试题100道

C#经典面试题100道