Given a sorted array, for example: // [2,5,6,8,11,12,15,18] Then we rotated it 1 time, it becomes: // [18, 2,5,6,8,11,12,15] 2 times: // [15,182,5,6,8,11,12] So now given you an array which is rotated N times based on an sorted array, try to find the…