Reported interview periodNot available
First position of a target in a sorted array
Given a nondecreasing array and a target value, report where the target first appears, or -1 when it is missing. A logarithmic search is expected, even though the same value may occur many times.
Practice focusRequirements - Line one is the element count n . Line two holds the n space-separated integers in nondecreasing order, and is empty when n is 0. Line three is the target. - Return the smallest zero-based index holding the target, as a decimal string with no padding. - Return -1 when the array is empty or the target never appears. - Repeated values are expected, so an ordinary equality hit is not enough; after a match keep searching to the left while remembering the best index seen. - Keep the running time logarithmic in n .…