LeetCode "Search Insert Position"

A simple 1D searching problem. Binary search of course.

But.. STL has already done it for you:

class Solution {
public:
    int searchInsert(int A[], int n, int target) {
        int *p = std::lower_bound(A, A+n, target); 
        return p - A;
    }
};
原文地址:https://www.cnblogs.com/tonix/p/3853353.html