mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
添加 0027.移除元素.md Java版本
This commit is contained in:
@ -123,6 +123,22 @@ public:
|
||||
|
||||
|
||||
Java:
|
||||
```java
|
||||
class Solution {
|
||||
public int removeElement(int[] nums, int val) {
|
||||
int p2 = 0;
|
||||
|
||||
for (int p1 = 0; p1 < nums.length; p1++) {
|
||||
if (nums[p1] != val) {
|
||||
nums[p2] = nums[p1];
|
||||
p2++;
|
||||
}
|
||||
}
|
||||
|
||||
return p2;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Python:
|
||||
|
||||
|
Reference in New Issue
Block a user