An easy c++ Runtime: 8 ms


  • 1
    R

    这题就是让你实现std::lower_bound()这个函数,我看有人竟然还用std::lower_bound()这个函数实现

    class Solution {
    public:
    	int searchInsert(vector<int>& nums, int target) {
    		vector<int>::size_type i=0;
    		for(i;i < nums.size();i++)
    		{
    			if(target <= nums[i])
    				return i;			
    		}
    		return i;
    	}
    };

Log in to reply
 

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