当前位置:网站首页>283. Moving zero-c and language assisted array method
283. Moving zero-c and language assisted array method
2022-07-04 22:02:00 【Mr Gao】
283. Move zero -c And language assisted array method
Given an array nums, Write a function that will 0 Move to end of array , While maintaining the relative order of non-zero elements .
Please note that , You must operate on the array in place without copying it .
Example 1:
Input : nums = [0,1,0,3,12]
Output : [1,3,12,0,0]
Example 2:
Input : nums = [0]
Output : [0]
For this question , We can have many algorithms to deal with this problem , But personally , Still use some conventional methods , It's not easy to have an accident , You can solve problems quickly and easily in the exam or interview , The solution code is as follows :
void moveZeroes(int* nums, int numsSize){
int aid[numsSize];
int size1=0;
int size2=0;
int i;
for(i=0;i<numsSize;i++){
if(nums[i]!=0){
nums[size1++]=nums[i];
}
else{
aid[size2++]=nums[i];
}
}
for(i=0;i<size2;i++){
nums[size1++]=aid[i];
}
}
边栏推荐
- 解读创客教育中的各类智能化组织发展
- What is business intelligence (BI), just look at this article is enough
- Bookmark
- vim 从嫌弃到依赖(23)——最后的闲扯
- 更强的 JsonPath 兼容性及性能测试之2022版(Snack3,Fastjson2,jayway.jsonpath)
- Enlightenment of maker thinking in Higher Education
- Bizchart+slider to realize grouping histogram
- 2022 version of stronger jsonpath compatibility and performance test (snack3, fastjson2, jayway.jsonpath)
- MP3是如何诞生的?
- GTEST from ignorance to proficient use (2) what is test fixture
猜你喜欢
[weekly translation go] how to code in go series articles are online!!
TCP protocol three times handshake process
Case sharing | integrated construction of data operation and maintenance in the financial industry
【公开课预告】:视频质量评价基础与实践
Exclusive interview of open source summer | new committer Xie Qijun of Apache iotdb community
案例分享|金融业数据运营运维一体化建设
【活动早知道】LiveVideoStack近期活动一览
Redis03 - network configuration and heartbeat mechanism of redis
Daily question-leetcode556-next larger element iii-string-double pointer-next_ permutation
Master the use of auto analyze in data warehouse
随机推荐
ACM Multimedia 2022 | 视觉语言预训练模型中社会偏见的反事实衡量和消除
AcWing 2022 每日一题
MP3是如何诞生的?
Is it safe to open an account in the stock of Caicai college? Can you only open an account by digging money?
从RepVgg到MobileOne,含mobileone的代码
[leetcode] 17. Letter combination of telephone number
学习突围3 - 关于精力
挖财学院股票开户安全吗?开户只能在挖财开户嘛?
Drop down selection of Ehlib database records
[optimtool.unconstrained] unconstrained optimization toolbox
Redis03 - network configuration and heartbeat mechanism of redis
Keep on fighting! The city chain technology digital summit was grandly held in Chongqing
如何借助自动化工具落地DevOps
输入的查询SQL语句,是如何执行的?
股票开户佣金最低多少,炒股开户佣金最低网上开户安全吗
力扣98:验证二叉搜索树
Delphi soap WebService server-side multiple soapdatamodules implement the same interface method, interface inheritance
vim 从嫌弃到依赖(23)——最后的闲扯
并列图的画法,多排多列
CloudCompare&Open3D DBSCAN聚类(非插件式)