当前位置:网站首页>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;
}
};
边栏推荐
- Ti millimeter wave radar learning (I)
- Classic literature reading -- deformable Detr
- Data playback partner rviz+plotjuggler
- Format check JS
- Google play academy team PK competition, official start!
- Shenji Bailian 3.54-dichotomy of dyeing judgment
- Picture clipping plug-in cropper js
- Current situation analysis of Devops and noops
- 如何使用MITMPROXy
- Scheme and implementation of automatic renewal of token expiration
猜你喜欢
随机推荐
memcached安装
BGP报文详细解释
Error creating bean with name 'instanceoperatorclientimpl' defined in URL when Nacos starts
让每一位开发者皆可使用机器学习技术
Frequently asked questions about jetpack compose and material you
51 single chip microcomputer - ADC explanation (a/d conversion, d/a conversion)
495. Timo attack
Replace Django database with MySQL (attributeerror: 'STR' object has no attribute 'decode')
图片裁剪插件cropper.js
借力 Google Cloud 基础设施和着陆区,构建企业级云原生卓越运营能力
AttributeError: ‘str‘ object has no attribute ‘decode‘
Summary of MySQL constraints
Contest3147 - game 38 of 2021 Freshmen's personal training match_ 1: Maximum palindromes
Contest3147 - game 38 of 2021 Freshmen's personal training match_ F: Polyhedral dice
Talking about MySQL database
From design delivery to development, easy and efficient!
Database learning summary 5
DRM display framework as I understand it
Deep learning classification network -- alexnet
深度学习分类网络 -- AlexNet