topic
Design an algorithm that is as efficient as possible in time to find the smallest positive integer that does not appear in the array
Algorithm idea
Trade time complexity for space complexity
code display
int find(int A[],int n){
int *B =(int*)malloc(sizeof(int)*n); //创建一个B数组,动态的可以增加大小的那种
for(int i=0;i<n;i++){
B[i]=0 //设置B刚开始都是0
for(int j=0;i<n;i++){
//开始跟A 给定的那个数组进行比较。
if(A[i]>0 || A[i]<=n){
B[A[i-1]=1];
for(i=0 ;i<n; ++i)
if(B[j==0];
break;
return i+1;
}