//在数组最后插入INT_MAX是个好方法class Solution { public: int searchInsert(vector<int>& nums, int target) { nums.push_back(INT_MAX); for(int i=0;i < nums.size();i++){ if(target <= nums[i]) return i; } } };