One line C++ STL solution.


  • 1
    M
    class Solution {
    public:
        int searchInsert(vector<int>& nums, int target) {
            return lower_bound(nums.begin(), nums.end(), target) - nums.begin();
        }
    };

Log in to reply
 

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