mirror of
https://github.com/chefyuan/algorithm-base.git
synced 2024-11-24 13:03:41 +00:00
feat(ml): leetcode27移除元素 添加 Python3 代码
This commit is contained in:
parent
107732a6c8
commit
f5da40eb54
@ -85,6 +85,8 @@ class Solution {
|
||||
|
||||
**题目代码:**
|
||||
|
||||
Java Code:
|
||||
|
||||
```java
|
||||
class Solution {
|
||||
public int removeElement(int[] nums, int val) {
|
||||
@ -106,3 +108,16 @@ class Solution {
|
||||
}
|
||||
```
|
||||
|
||||
Python3 Code:
|
||||
|
||||
```py
|
||||
class Solution:
|
||||
def removeElement(self, nums: List[int], val: int) -> int:
|
||||
i = 0
|
||||
for j in range(len(nums)):
|
||||
if nums[j] != val:
|
||||
nums[i] = nums[j]
|
||||
i += 1
|
||||
return i
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user