Create 35. Search Insert Position.md

This commit is contained in:
唐树森 2018-09-01 19:07:16 +08:00 committed by GitHub
parent 8f17821712
commit aceaed72c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,16 @@
# [Search Insert Position](https://leetcode.com/problems/remove-element/description/)
# 思路
排序数组查找肯定就是二分法啦,但是题目没说一定是增序,根据结果来看应该全是增序。
# C++
```
class Solution {
public:
int removeElement(vector<int>& nums, int val) {
int count = 0;
for(int i = 0; i < nums.size(); i++){
if(nums[i] != val) nums[count++] = nums[i];
}
return count;
}
};
```