Question: Problem 1. [Category: Coding] Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target
Problem 1. [Category: Coding] Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. If target is not found in the array, return [-1, -1]. You must write an algorithm with O(log(n)) run time complexity, implement your algorithm in your favorite language. Example: Input: nums = [5,7,7,8,8,10], target = 8 Output: [3,4] Input: nums = [5,7,7,8,8,10], target = 6 Output: [-1,-1]
Step by Step Solution
There are 3 Steps involved in it
To solve Problem 1 you can use a modified version of the binary search algorithm Since the array is ... View full answer
Get step-by-step solutions from verified subject matter experts
