Past Challenges

32. Find First and Last Position of Element in Sorted Array

60%

Write a function solve that finds the starting and ending position of a target value in a sorted array. If the target is not found, return [-1,-1]. Ideally, your solution should run in O(logn) time.

Example: Input: [5,7,7,8,8,10], 8 Output: [3,4]

Make sure you return your solution, don't print!

Python3

def solve(nums, target):
    pass