当前位置:网站首页>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;
}
};
边栏推荐
- 51 single chip microcomputer - ADC explanation (a/d conversion, d/a conversion)
- Redis Key-Value数据库 【秒杀】
- Stc8h8k series assembly and C51 actual combat - serial port sending menu interface to select different functions
- 神机百炼3.54-染色法判定二分图
- 如何使用MITMPROXy
- 网络相关知识(硬件工程师)
- Problems encountered in uni app development (continuous update)
- STC8H8K系列匯編和C51實戰——數碼管顯示ADC、按鍵串口回複按鍵號與ADC數值
- 【C语言】简单实现扫雷游戏
- Web page user step-by-step operation guide plug-in driver js
猜你喜欢
随机推荐
Problems encountered in uni app development (continuous update)
ROS2----LifecycleNode生命周期节点总结
外部中断无法进入,删代码再还原就好......记录这个想不到的bug
Community theory | kotlin flow's principle and design philosophy
WLAN相关知识点总结
Format check JS
MUI底部导航的样式修改
Spark overview
Brain and cognitive neuroscience matlab psychoolbox cognitive science experimental design - experimental design 4
Talking about MySQL database
神机百炼3.54-染色法判定二分图
MySQL transaction and isolation level
Page printing plug-in print js
Error creating bean with name 'instanceoperatorclientimpl' defined in URL when Nacos starts
BGP报文详细解释
How to use mitmproxy
神机百炼3.52-Prim
网络相关知识(硬件工程师)
keepalived安装使用与快速入门
uni-app开发中遇到的问题(持续更新)









