Class Solution
java.lang.Object
g0001_0100.s0034_find_first_and_last_position_of_element_in_sorted_array.Solution
34 - Find First and Last Position of Element in Sorted Array.<p>Medium</p>
<p>Given an array of integers <code>nums</code> sorted in non-decreasing order, find the starting and ending position of a given <code>target</code> value.</p>
<p>If <code>target</code> is not found in the array, return <code>[-1, -1]</code>.</p>
<p>You must write an algorithm with <code>O(log n)</code> runtime complexity.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [5,7,7,8,8,10], target = 8</p>
<p><strong>Output:</strong> [3,4]</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [5,7,7,8,8,10], target = 6</p>
<p><strong>Output:</strong> [-1,-1]</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> nums = [], target = 0</p>
<p><strong>Output:</strong> [-1,-1]</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>0 <= nums.length <= 10<sup>5</sup></code></li>
<li><code>-10<sup>9</sup> <= nums[i] <= 10<sup>9</sup></code></li>
<li><code>nums</code> is a non-decreasing array.</li>
<li><code>-10<sup>9</sup> <= target <= 10<sup>9</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
searchRange
public int[] searchRange(int[] nums, int target)
-