027 - Remove Element
2015-11-11 18:33
162 查看
Given an array and a value, remove all instances of that value in place and return the new length.
The order of elements can be changed. It doesn't matter what you leave beyond the new length.
给定一个数组,移除指定的元素
int removeElement(int* nums, int numsSize, int val)
{
int k = 0, i;
for (i = 0; i < numsSize; i++) {
if (nums[i] != val) nums[k++] = nums[i];
}
return k;
}
The order of elements can be changed. It doesn't matter what you leave beyond the new length.
给定一个数组,移除指定的元素
int removeElement(int* nums, int numsSize, int val)
{
int k = 0, i;
for (i = 0; i < numsSize; i++) {
if (nums[i] != val) nums[k++] = nums[i];
}
return k;
}
相关文章推荐
- LightOJ 1369 - Answering Queries(规律)
- mysql主备复制搭建
- cmd复制粘贴
- 好的代码风格积累
- jquery获取屏幕尺寸方法
- 026 - Remove Duplicates from Sorted Array
- Android学习路线图
- 学习嵌入式的捷径
- 关于systemd的service超时时间设定
- 主库磁盘满,从库io线程报错Got fatal error 1236 from master when reading data from binary log
- 用纯JavaScript替代jQuery的技巧
- 025 - Reverse Nodes in k-Group
- 系统功能在用户测试阶段被推翻
- SQL server数据库内置账户SA登录设置
- 数值分析 反幂法求矩阵按模最小特征值 MATLAB实现
- JSON.parse()和JSON.stringify()
- 024 - Swap Nodes in Pairs
- Visual Studio 2010 安装 MSDN Library
- Git SSH Key 生成步骤
- SQLite的基本使用 与FMDB框架的使用