Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf1ce863

Browse files
authored
Merge pull requestneetcode-gh#234 from lt77777/patch-3
Create 27-Remove-Element
2 parentsac20d27 +ae26df5 commitf1ce863

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

‎27-Remove-Element.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
classSolution(object):
2+
defremoveElement(self,nums,val):
3+
"""
4+
:type nums: List[int]
5+
:type val: int
6+
:rtype: int
7+
"""
8+
foriinrange(nums.count(val)):# loop how many val is in the list
9+
nums.remove(val)# remove each val one by one
10+
returnlen(nums)# return len of nums

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp