@@ -0,0 +1,1126 @@
+# Time:  O(logn)%0A# Space: O(1)%0A%0A# Given a sorted (in ascending order) integer array nums of n elements%0A# and a target value, write a function to search target in nums.%0A# If target exists, then return its index, otherwise return -1.%0A#%0A# Example 1:%0A#%0A# Input: nums = %5B-1,0,3,5,9,12%5D, target = 9%0A# Output: 4%0A# Explanation: 9 exists in nums and its index is 4%0A#%0A# Example 2:%0A#%0A# Input: nums = %5B-1,0,3,5,9,12%5D, target = 2%0A# Output: -1%0A# Explanation: 2 does not exist in nums so return -1%0A#%0A# Note:%0A# - You may assume that all elements in nums are unique.%0A# - n will be in the range %5B1, 10000%5D.%0A# - The value of each element in nums will be in the range %5B-9999, 9999%5D.%0A%0A%0Aclass Solution(object):%0A    def search(self, nums, target):%0A        %22%22%22%0A        :type nums: List%5Bint%5D%0A        :type target: int%0A        :rtype: int%0A        %22%22%22%0A        left, right = 0, len(nums)-1%0A        while left %3C= right:%0A            mid = left + (right-left)//2%0A            if nums%5Bmid%5D %3E target:%0A                right = mid-1%0A            elif nums%5Bmid%5D %3C target:%0A                left = mid+1%0A            else:%0A                return mid%0A        return -1%0A

Create binary-search.py