Solve in Python:
Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.

Your algorithm's runtime complexity must be in the order of O(log n).

If the target is not found in the array, return [-1, -1].

Example 1:


Input: nums = [5,7,7,8,8,10], target = 8
Output: [3,4]

Example 2:


Input: nums = [5,7,7,8,8,10], target = 6
Output: [-1,-1]
class Solution:
     def searchRange(self, nums, target):
         """
         :type nums: List[int]
         :type target: int
         :rtype: List[int]
         """
         #m = int(len(nums)/2)
         #upper, lower = nums[:m], nums[m:]
         s, e = -1, -1
         l, u = 0, len(nums)-1
         if not nums or target > nums[u] or target < nums[l]:
             return [s, e]
         m = int((l+u)/2)
         while u >= l:
             if nums[m] > target:
                 if m == u:
                     break
                 u = m
                 #if int((l+u)/2) == u:
                 #    break
                 m = int((l+u)/2)
             elif nums[m] < target:
                 l = m
                 if int((l+u)/2) == l:
                     m = l+1
                 else:
                     m = int((l+u)/2)
             else:
                 s = e = m
                 while 0 < s and nums[s-1] == nums[s]:
                     s-=1
                 while e < len(nums)-1 and nums[e+1] == nums[e]:
                     e+=1
                 break
         return [s, e]