很敏感的信息提示:二分
int GetMissing(int A[], int n)
{
assert(A && n > 0);
int nBeg = 0;
int nEnd = n-1;
while (nBeg < nEnd)
{
int nMid = (nBeg + nEnd)/2;
if (A[nMid] != nMid + 1)
nEnd = nMid;
else
nBeg = nMid + 1;
}
return A[nEnd];
}