Hello๐,
*My name is Alex and I'm maker of Devmates.co. ๐
We are resolving daily coding problems which asked by top tech companies together. We share our solutions, give some help if anyone stuck, support each other and just hangout together in the internet. ๐ปโ๏ธ๐ฌ
I get this problem from our members or just searching them in the internet(leetcode forums, Glassdoor, teamblind, etc.). Sometimes this problem can be very easy, sometimes too ๐ทโโ๏ธhard, everything depends on skills but we are trying to resolve all of them and Have Fun. ๐
Today I want to share problem which was asked by ๐ข Google.
Problem:
Find the starting and ending position of a given target value in array of integers nums sorted in ascending order.
If the target is not found in the array, return [-1, -1].
Example:
Input: nums = [3,4,7,7,9,9,9,10], target = 9
Output: [4,6]
Input: nums = [3,4,7,7,9,9,9,10], target = 8
Output: [-1,-1]
Your algorithm's runtime complexity must be in the order of O(log n)
Top comments (1)