feat(ml): leetcode27移除元素 添加 Python3 代码

This commit is contained in:
lucifer 2021-04-26 14:48:29 +08:00 committed by GitHub
parent 107732a6c8
commit f5da40eb54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,6 +85,8 @@ class Solution {
**题目代码** **题目代码**
Java Code:
```java ```java
class Solution { class Solution {
public int removeElement(int[] nums, int val) { 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
```