作者新建立的社区:https://bbs.csdn.net/forums/FKBZM?typeId=22226💖💛💙
期待hxd的支持哈🎉 🎉 🎉
leetcode 27
?
int removeElement(int* nums, int numsSize, int val){
int pre=0;
int cur=0;
while(cur<numsSize)
{
if(nums[cur]!=val)
{
nums[pre]=nums[cur];
cur++;
pre++;
}
else
{
cur++;
}
}
return pre;
}
leetcode 189
?
void reverse(int* arr,int begin,int end)
{
while(begin<=end)
{
int tmp=arr[begin];
arr[begin]=arr[end];
arr[end]=tmp;
begin++;
end--;
}
}
void rotate(int* nums, int numsSize, int k){
k %= numsSize;
reverse(nums,0,numsSize-k-1);
reverse(nums,numsSize-k,numsSize-1);
reverse(nums,0,numsSize-1);
return nums;
}
?
|