Solution to search rotated sorted array