Search Insert Position

插入排序

    int searchInsert(int A[], int n, int target) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        int i;
        for(i = 0; i < n; i++){
            if(A[i] >= target)
                return i;
            else if(A[i] < target)
                continue;
        }
        if(i == n)
            return n;
    }

 

posted on 2013-09-21 19:46  waruzhi  阅读(113)  评论(0编辑  收藏  举报

导航