Skip to content

Commit f5da40e

Browse files
authored
feat(ml): leetcode27移除元素 添加 Python3 代码
1 parent 107732a commit f5da40e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

animation-simulation/数组篇/leetcode27移除元素.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ class Solution {
8585

8686
**题目代码:**
8787

88+
Java Code:
89+
8890
```java
8991
class Solution {
9092
public int removeElement(int[] nums, int val) {
@@ -106,3 +108,16 @@ class Solution {
106108
}
107109
```
108110

111+
Python3 Code:
112+
113+
```py
114+
class Solution:
115+
def removeElement(self, nums: List[int], val: int) -> int:
116+
i = 0
117+
for j in range(len(nums)):
118+
if nums[j] != val:
119+
nums[i] = nums[j]
120+
i += 1
121+
return i
122+
```
123+

0 commit comments

Comments
 (0)