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:
|
||||||
|
```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:
|
Python:
|
||||||
|
|
||||||
@ -172,4 +188,4 @@ var removeElement = (nums, val) => {
|
|||||||
* 作者微信:[程序员Carl](https://mp.weixin.qq.com/s/b66DFkOp8OOxdZC_xLZxfw)
|
* 作者微信:[程序员Carl](https://mp.weixin.qq.com/s/b66DFkOp8OOxdZC_xLZxfw)
|
||||||
* B站视频:[代码随想录](https://space.bilibili.com/525438321)
|
* B站视频:[代码随想录](https://space.bilibili.com/525438321)
|
||||||
* 知识星球:[代码随想录](https://mp.weixin.qq.com/s/QVF6upVMSbgvZy8lHZS3CQ)
|
* 知识星球:[代码随想录](https://mp.weixin.qq.com/s/QVF6upVMSbgvZy8lHZS3CQ)
|
||||||
<div align="center"><img src=../pics/公众号.png width=450 alt=> </img></div>
|
<div align="center"><img src=../pics/公众号.png width=450 alt=> </img></div>
|
||||||
|
Reference in New Issue
Block a user