Solving Search in Rotated Sorted Array in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.

Problem Description

Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.

You may assume no duplicate exists in the array.

Example 1:

Input: nums = [4,5,6,7,0,1,2], target = 0
Output: 4

Example 2:

Input: nums = [4,5,6,7,0,1,2], target = 3
Output: -1

See the full details of the problem Search in Rotated Sorted Array at LeetCode

Originally posted at: