diff --git a/problems/0027.移除元素.md b/problems/0027.移除元素.md index 144cd5be..959474fc 100644 --- a/problems/0027.移除元素.md +++ b/problems/0027.移除元素.md @@ -124,9 +124,19 @@ public: Java: - Python: +```python +class Solution: + def removeElement(self, nums: List[int], val: int) -> int: + i,n = 0,len(nums) + for j in range(n): + if nums[j] != val: + nums[i] = nums[j] + i += 1 + return i +``` + Go: ```go @@ -162,4 +172,4 @@ var removeElement = (nums, val) => { * 作者微信:[程序员Carl](https://mp.weixin.qq.com/s/b66DFkOp8OOxdZC_xLZxfw) * B站视频:[代码随想录](https://space.bilibili.com/525438321) * 知识星球:[代码随想录](https://mp.weixin.qq.com/s/QVF6upVMSbgvZy8lHZS3CQ) -