Merge pull request #13 from azl397985856/patch-2

feat(ml): leetcode27移除元素 添加 Python3 代码
pull/17/head
算法基地 2021-04-26 15:04:26 +08:00 committed by GitHub
commit df9a5805e9
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
```