class Solution {
public:
int search(vector<int>& nums, int target) {
int left=0;
int right=nums.size()-1;
while(left<=right)
{
int mid=(left+right)/2;
if(target>nums[mid])
left=mid+1;
else if(target<nums[mid])
right=mid-1;
else
{
return mid;
}
}
return -1;
}
};
class Solution {
public:
int removeElement(vector<int>& nums, int val) {
int left=0;
int right=0;
for(;left<nums.size();left++)
{
if(nums[left]!=val)
{
nums[right++]=nums[left];
}
}
return right;
}
};