(int[] nums, int target)
| 10 | */ |
| 11 | public class Solution { |
| 12 | public int searchInsert(int[] nums, int target) { |
| 13 | int left = 0, right = nums.length - 1, mid = (right + left) >> 1; |
| 14 | while (left <= right) { |
| 15 | if (target <= nums[mid]) right = mid - 1; |
| 16 | else left = mid + 1; |
| 17 | mid = (right + left) >> 1; |
| 18 | } |
| 19 | return left; |
| 20 | } |
| 21 | |
| 22 | public static void main(String[] args) { |
| 23 | Solution solution = new Solution(); |