My answer is similar to yours. But we don't have to check duplicated items in every loop, instead we check once.

class Solution {
public:
bool search(vector<int>& nums, int target) {
if(nums.size() == 0) return false;
// Find the non-duplicated head: h
int h = 0;
while(h != nums.size()-1 && nums[h] == nums[nums.size()-1]) h++;
// Previous algorithm can deal with duplicated items if the head of array is not a duplicated item
int L = h, R = nums.size()-1, M = (L+R)/2;
while(L < R){
if(nums[M] == target)
return true;
else if((nums[h] <= target) ^ (target <= nums[M]) ^ (nums[M] < nums[h]) == false)
R = M;
else
L = M+1;
M = (L+R)/2;
}
return (L == R && nums[L] == target)? true : false;
}
};