当前位置:网站首页>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;
}
};
边栏推荐
猜你喜欢

数据回放伴侣Rviz+plotjuggler

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

借力 Google Cloud 基础设施和着陆区,构建企业级云原生卓越运营能力

Mathematical statistics and machine learning

WLAN相关知识点总结

神机百炼3.54-染色法判定二分图

51 single chip microcomputer - ADC explanation (a/d conversion, d/a conversion)

How vite is compatible with lower version browsers

Ti millimeter wave radar learning (I)

Spark overview
随机推荐
ROS2----LifecycleNode生命周期节点总结
来自读者们的 I/O 观后感|有奖征集获奖名单
WLAN相关知识点总结
Stc8h8k series assembly and C51 actual combat - digital display ADC, key serial port reply key number and ADC value
Mock simulate the background return data with mockjs
MUI底部导航的样式修改
The official zero foundation introduction jetpack compose Chinese course is coming!
STC8H8K系列匯編和C51實戰——數碼管顯示ADC、按鍵串口回複按鍵號與ADC數值
官方零基础入门 Jetpack Compose 的中文课程来啦!
495. Timo attack
Comment utiliser mitmproxy
Zhuanzhuanben - LAN construction - Notes
如何使用MITMPROXy
Cookie plugin and localforce offline storage plugin
Flutter hybrid development: develop a simple quick start framework | developers say · dtalk
Ti millimeter wave radar learning (I)
Web components series (VIII) -- custom component style settings
Leverage Google cloud infrastructure and landing area to build enterprise level cloud native excellent operation capability
Contest3147 - game 38 of 2021 Freshmen's personal training match_ 1: Maximum palindromes
Format check JS