Search in Rotated Sorted Array with new condition in while loop