27. Remove Element
来源:互联网 发布:linux ipython 编辑:程序博客网 时间:2024/06/06 11:41
Given an array and a value, remove all instances of that value in place and return the new length.
Do not allocate extra space for another array, you must do this in place with constant memory.
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) {int i=0,k=0;
while(i<nums.length){
if(nums[i]!=val)
nums[k++]=nums[i];
i++;
}
return k;
}
}
0 0
- [LeetCode]27.Remove Element
- LeetCode --- 27. Remove Element
- LeetCode 27.Remove Element
- [Leetcode] 27. Remove Element
- 27.Remove Element
- [Leetcode] 27.Remove Element
- 27. Remove Element
- 27. Remove Element
- 【leetcode】27. Remove Element
- 【leetcode】27. Remove Element
- 27. Remove Element
- 27. Remove Element
- 27. Remove Element
- Leetcode 27. Remove Element
- 27. Remove Element
- LeetCode 27. Remove Element
- 27. Remove Element LeetCode
- 27. Remove Element
- 三目运算符
- git pull 出错 fatal: Could not read from remote repository.Please make sure you have the correct acces
- leetCode练习(100)
- POJ 1278(细节prim)
- Codeforces 118D Caesar's Legions【dp】好题
- 27. Remove Element
- 查找算法——找到序列中第二大的数
- 加速审核网址
- Android城市选择列表(一)——RecyclerView数据分组
- POJ-2195 Going Home(最小费用最大流)
- 转发保留不错一篇 数学模型神经网络在程序化交易模型构建中的运用探讨
- 常对象常引用等的一些理解
- 机器学习笔记
- 第一周 从问题到C语言程序设计的程序