My simple C++ solution 4 line


  • 0
    L

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


Log in to reply
 

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