mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-10 04:06:51 +08:00
添加0027.移除元素 Python3版本
This commit is contained in:
@ -124,9 +124,19 @@ public:
|
|||||||
|
|
||||||
Java:
|
Java:
|
||||||
|
|
||||||
|
|
||||||
Python:
|
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:
|
||||||
```go
|
```go
|
||||||
|
Reference in New Issue
Block a user