given an array of integers nums sorted in ascending order find the starting and ending position of a given target value if the target is not found in the array return 1 1 for example input nums 5 7 7 8 8 8 10 target 8 output 3 5 input nums 5 7 7 8 8 8 10 target 11 output 1 1 type nums listint type target int rtype listint breaks at low high both pointing to first occurence of target type nums list int type target int rtype list int breaks at low high both pointing to first occurence of target
def search_range(nums, target):
    
    low = 0
    high = len(nums) - 1
    
    
    while low < high:
        mid = low + (high - low) // 2
        if target <= nums[mid]:
            high = mid
        else:
            low = mid + 1

    for j in range(len(nums) - 1, -1, -1):
        if nums[j] == target:
            return [low, j]

    return [-1, -1]