[LeetCode]Remove Element
LeetCode Element remove
2023-09-11 14:14:10 时间
题目:给定一个数字集合A。要求去除集合A中全部的elem,并返回新集合A的长度
算法:遍历覆盖
public class Solution { public int removeElement(int[] A, int elem) { int length = 0; for (int i=0; i<A.length; ++i) { if (elem != A[i]) { A[length++] = A[i]; } } return length; } }
相关文章
- Leetcode: Binary Watch
- Leetcode: Kth Smallest Element in a Sorted Matrix
- Leetcode: Find Peak Element
- Leetcode: Majority Element
- Leetcode: Regular Expression Matching
- Remove Linked List Elements -- leetcode
- [LeetCode] Kth Smallest Element in a BST
- [LeetCode] Unique Binary Search Trees II
- [LeetCode] Combination Sum
- Leetcode Gray Code
- 【LeetCode】169. Majority Element
- [LeetCode] 986. Interval List Intersections 区间列表的交集
- [LeetCode] Stickers to Spell Word 贴片拼单词
- [LeetCode] Single Element in a Sorted Array 有序数组中的单独元素
- [LeetCode] 229. Majority Element II 求大多数之二
- [LeetCode] 215. Kth Largest Element in an Array 数组中第k大的数字
- [LeetCode] Binary Search Tree Iterator 二叉搜索树迭代器
- Leetcode——27. Remove Element
- leetcode 227. Basic Calculator II 基本计算器 II(中等)
- leetcode 503. Next Greater Element II 下一个更大元素 II(中等)
- leetcode 48. Rotate Image 旋转图像(Medium)