5 lines c++ code


  • 0
    A

    class Solution {
    public:
    int searchInsert(vector<int>& nums, int target) {
    int low = distance(nums.begin(), lower_bound(nums.begin(), nums.end(), target));
    if(low <= nums.size() - 1)
    return low;
    else
    return nums.size();
    }
    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.