移动零
来源:互联网 发布:南京雨花台区网络问政 编辑:程序博客网 时间:2024/05/01 06:29
题目要求:在不改变数组中元素顺序的前提下,将数组中的零元素移至数组末尾;
version one
由于题目过于简单,这里就只贴出一种方案,复杂度为
void moveZeroes(vector<int>& nums) { // Write your code here vector<int>::iterator it; size_t pos = 0; for(it = nums.begin(); it != nums.end(); it++) { if(*it !=0) { nums[pos++] = *it; } } for(; pos != nums.size(); pos++) { nums[pos] =0; } }
0 0
- 移动零
- 移动零
- 移动零
- 移动零
- 移动零
- 移动零
- 移动零
- 移动零
- 移动零
- 移动零 Move Zeroes
- 移动零-lintCode
- 539移动零
- LintCode:移动零
- LintCode539:移动的零
- LintCode - 539.移动零
- LintCode 539 移动零
- Java实现-移动零
- Lintcode 移动零
- UTF-16编码详解
- 关于chrome浏览器-webkit-autofil覆盖input样式问题解决方案
- Telephony之PhoneInterfaceManager
- C++在嵌入式系统上的应用
- 遍赏各国“佳丽”——玩家侃老镜头
- 移动零
- HTTP和HTTPS详解
- Android 水波纹点击效果
- makefile文件的编写,目标文件作为目标是否多余?
- android studio中断开SVN连接,并彻底清理项目中的.svn文件
- 大乐透 不明白
- 【洛谷 1219】八皇后
- java.lang.NullPointerException:Attempt to invoke virtual method xxx on a null object reference
- codeforece 768 B. Code For 1