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

pull/13/head
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
1 changed files with 15 additions and 0 deletions

View File

@ -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
```