当前位置:网站首页>LeetCode 283. Move zero
LeetCode 283. Move zero
2022-07-02 06:10:00 【Great white sheep_ Aries】
Title Description
solution
This question is actually LeetCode 27. Remove elements Extension of , take 0 Just delete it all and fill it up
class Solution {
public:
void moveZeroes(vector<int>& nums) {
int p = removeElement(nums, 0);
for (; p < nums.size(); p++)
nums[p] = 0;
}
int removeElement(vector<int>& nums, int val) {
if (nums.size() == 0) return 0;
int slow = 0, fast = 0;
while (fast < nums.size())
{
if (nums[fast] != val)
{
nums[slow] = nums[fast];
slow++;
}
fast++;
}
return slow;
}
};
边栏推荐
- memcached安装
- 495. Timo attack
- cookie插件和localForage离线储存插件
- CNN可视化技术 -- CAM & Grad-CAM详解及pytorch简洁实现
- WLAN相关知识点总结
- MUI底部导航的样式修改
- Replace Django database with MySQL (attributeerror: 'STR' object has no attribute 'decode')
- 深度学习分类网络 -- AlexNet
- STC8H8K系列汇编和C51实战——串口发送菜单界面选择不同功能
- Some descriptions of Mipi protocol of LCD
猜你喜欢

深度学习分类网络--VGGNet

Mathematical statistics and machine learning

WLAN相关知识点总结

Eco express micro engine system has supported one click deployment to cloud hosting

Linkage between esp8266 and stc8h8k single chip microcomputer - Weather Clock

谷歌出海创业加速器报名倒计时 3 天,创业人闯关指南提前收藏!

深度学习分类网络--Network in Network

穀歌出海創業加速器報名倒計時 3 天,創業人闖關指南提前收藏!

Introduce uview into uni app

Comment utiliser mitmproxy
随机推荐
Classic literature reading -- deformable Detr
如何使用MITMPROXy
Contest3145 - the 37th game of 2021 freshman individual training match_ H: Eat fish
Jetpack Compose 与 Material You 常见问题解答
使用sha256文件验证下载的文件
JWT tool class
Format check JS
线性dp(拆分篇)
JS determines whether the mobile terminal or the PC terminal
Nacos 启动报错 Error creating bean with name ‘instanceOperatorClientImpl‘ defined in URL
memcached安装
[C language] screening method for prime numbers
Shenji Bailian 3.53-kruskal
ESP8266与STC8H8K单片机联动——天气时钟
492.构造矩形
Contest3147 - game 38 of 2021 Freshmen's personal training match_ E: Listen to songs and know music
Problems encountered in uni app development (continuous update)
Mock simulate the background return data with mockjs
ROS2----LifecycleNode生命周期节点总结
经典文献阅读之--Deformable DETR