Leetcode Remove Element
2015-09-09 13:46
253 查看
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.
Java Code:
Reference:
1. http://www.cnblogs.com/EdwardLiu/p/3703444.html
The order of elements can be changed. It doesn't matter what you leave beyond the new length.
Java Code:
public int removeElement(int[] nums, int val) { int count = 0; for(int i = 0; i< nums.length; i++) { if(nums[i] != val) { nums[count] = nums[i]; count++; } } return count; }
Reference:
1. http://www.cnblogs.com/EdwardLiu/p/3703444.html
相关文章推荐
- Objective-C中的Block
- 动画《魁拔妖侠传》反思
- Zabbix教程-Zabbix配置文件详解
- Uva 1632 alibaba 区间dp
- 设计模式 - 观察者模式
- 处理文字过长显示超出解决方案(纯css解决)
- hdu4864Task(馋)
- 自动装箱和拆箱所带来的问题(1)“==”问题
- 【Xamarin 在Mac OS 上的部署安装环境】
- 《微历史.王牧》观后感
- 使用Struts 2将客户端JSON数据映射为服务器端Java对象
- 至linuxNIC添加多个IP
- Spring part 4:数据库连接池的配置
- Linux : misc_register、 register_chrdev 的区别总结
- Spring事务配置的5种方式
- 我对《周洪宇论第三次工业革命》一些看法
- qt多线程编程之QThread
- 栈的两种实现方式:数组和链表
- 齐次坐标的理解
- 工作总结