Remove Element
来源:互联网 发布:电流转换器淘宝 编辑:程序博客网 时间:2024/06/07 01:57
题目:
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.
思路:
和上一道题几乎一样的。。。
public class Solution { public int removeElement(int[] nums, int val) { if(nums == null) { return 0; } int count = 0; for(int i = 0;i < nums.length;i++) { if(nums[i] != val) { nums[count++] = nums[i]; } } return count; }}
0 0
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- 【jQuery】[attribute=value]属性选择器
- 关于GCD的一些总结
- Android之MVP 模式:简单易懂的介绍方式
- 【原创】轻量级移动设备即时通讯技术MobileIMSDK的常见问题解答
- 文章标题
- Remove Element
- zookeeper实现服务器端监控代码实现
- 条件概率 全概率 贝叶斯公式
- ssh
- 详解虚拟机中为Linux添加硬盘
- 一只神奇的asp小马
- 【bzoj1009】[HNOI2008]GT考试
- XAMPP的使用——Java转PHP初步学习的过程
- Spring AOP切入点表达式