Skip to main content

🟢 剑指 Offer II 068. 查找插入位置

LeetCode 提示

题目难度 简单

原题链接 🔗 leetcode

题解1#

class Solution {    public int searchInsert(int[] nums, int target) {        int lo=0, hi=nums.length, mid;
        while (lo < hi) {            mid = (lo+hi) / 2;            if (nums[mid] >= target) {                hi = mid;            } else {                lo = mid+1;            }        }
        return lo;    }}