human
I found an interesting problem on https://leetcode.com/problems/search-for-a-range/:
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]

I tried it in Python, but could not do it. Can you solve it?

=====
What is a Python code to find the starting and ending position of a given target value?
assistant
#Here is Python code to find the starting and ending position of a given target value.

class Solution:
     def searchRange(self, nums, target):
         """
         :type nums: List[int]
         :type target: int
         :rtype: List[int]
         """
         s, e = -1, -1
         l, u = 0, len(nums)
         if not nums or target > nums[u-1] or target < nums[l]:
             return [s, e]
         m = (l+u)//2
         while u > l:
             if nums[m] > target:
                 u = m
                 m = (l+u)//2
             elif nums[m] < target:
                 l = m+1
                 m = (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]