class Solution {
public:
bool search(int A[], int n, int target) {
int i=0,index=0;
for(i=1;i<n;i++)
if(A[i]!=A[index]) A[++index]=A[i];
int low=0,high=index;
int mid;
while(low<=high){
mid=(low+high)>>1;
//if (A[mid]==target) return mid;
if(A[low]>A[mid]){
if (A[mid]==target) return true;
if(target>A[mid]&&target<=A[high]) low=mid+1;
else high=mid1;
}
else {
if (A[mid]==target) return mid;
if(target<A[mid]&&target>=A[low]) high=mid1;
else low=mid+1;
}
}
return false;
}
};
I squeeze the array to one with no duplicates and then follows the method of the above，but the answer is wrong


No, you do want the existence, but to remove the duplicates, you need to know what the value of each element is. Shangrila's point was that since you are checking for duplicates, why not just check for the given node?
Assume the node you are looking for is a duplicate. Then with your algorithm, you'll find the node and remove all duplicates of it before searching the array of singletons for the node you already found. Just stop when you find it and would check for the duplicates. If you don't find it in your search for duplicates, then it isn't in the array and you can skip the binary search.