Skip to content

Commit

Permalink
Update InterviewTest3.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
clxchen committed Mar 7, 2018
1 parent 7d01fda commit ad3e5e9
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion InterviewTest3.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
aa
//for finding the duplicate number

bool duplicate(int numbers[],int length, int* duplication)
{
if(numbers == nullptr || length <=0)
return false;
for(int i = 0; i < length;++i)
{
if(numbers[i] < 0 || numbers[i] >length - 1)
return false;
}
for(int i = 0; i< length ; ++i)
{
while(numbers[i] != i)
{
if( numbers[i] = numbers[numbers[i]])
return true;
//交换两数
int temp = numbers[i];
numbers[i] = numbers[temp];
numbers[temp] = temp;
}
}
}

0 comments on commit ad3e5e9

Please sign in to comment.