solution to search a sorted and rotated array