标签:log code 思路 search div solution pos get arch
思路:注意特殊情况的处理,如[1]:0,[1]:2
class Solution { public: int searchInsert(vector<int>& nums, int target) { int index = -1, i = 0; for(; i<nums.size(); ++i) { if(nums[i] == target) return i; if(nums[i] < target) index = i; } return index+1; } };
标签:log code 思路 search div solution pos get arch
原文地址:http://www.cnblogs.com/chengyuz/p/6648910.html