3月3日(2) Search Insert Position

这题...有点简单吧,为什么只有34%的通过率?

题目意思简单说就是查找index,或者按升序插入的未知,WA一次,罪过,下次要特别注意程序里变量的变化,提交前用样例检查。

简单的我有点不好意思贴代码,实话..

class Solution {
public:
    int searchInsert(int A[], int n, int target) {
        int i = 0;
        for (i = 0; i<n; ++i)
        {
            if (target <= A[i]) return i;
        }
        return i;
    }
};
原文地址:https://www.cnblogs.com/seenthewind/p/3578259.html