您的位置:首页 > 其它

[LeetCode] Remove Element

2014-05-17 11:47 253 查看
和上一题类似,没有太大难度。

public class Solution {
public int removeElement(int[] A, int elem) {
if (A == null || A.length == 0) {
return 0;
}

int count = 0;
for (int next = 0; next < A.length ;++next) {
if (A[next] != elem) {
A[count++] = A[next];
}
}
return count;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: