25. Remove Element
2015-10-19 12:04
260 查看
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.
分析:
The order of elements can be changed. It doesn't matter what you leave beyond the new length.
分析:
public int removeElement(int[] nums, int val) { int len = nums.length; int pos = 0; for(int i=0;i<len;i++){ if(nums[i]!=val){ nums[pos]=nums[i]; pos++; } } return pos; }
相关文章推荐
- [LintCode] Longest Increasing Subsequence 最长递增子序列
- 东北四省杯经验
- easyUI 数据表格-datagrid
- 欢迎使用CSDN-markdown编辑器
- 手把手教你写Linux I2C设备驱动 tvp5158
- 基于jQury的UI框架 easyUI
- Redis学习笔记
- 深度学习(十三)caffe之训练数据格式
- oracle pl/sql之sql语法
- PostgreSQL
- JAVA使用apache http组件发送POST请求
- jQuery
- Xmanager远程连接Linux服务器图形界面--DZY
- 操作系统——进程
- php异步http请求
- IOS笔记UI--侧滑效果的实现
- 构造函数/拷贝构造函数/赋值构造函数
- 排版----缩略语(<title>)
- Redis Java连接使用
- 到底是哪里出了问题?