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

Commit02c2b65

Browse files
authored
Update 0027-remove-element.py
1 parent6af839b commit02c2b65

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎python/0027-remove-element.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ def removeElement(self, nums: List[int], val: int) -> int:
77
k+=1
88
returnk
99

10-
11-
classSolution2:
10+
# Optimized solution with the same time and space complexity
11+
classSolution:
1212
defremoveElement(self,nums:List[int],val:int)->int:
1313
# Avoid unessary copy operations in a previous solution, when k == i and nums[i] != val
1414
# by swapping nums[i] and the last element of the array (nums[n])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp