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

Commit083ce97

Browse files
Update linked_list.py
# Deletes all instances of given value in list. changes in that particular filewhen we are deleting a node in that particular case we do not need to update the prev value otherwise prev will be pointed to the deleted node. So in the updated code, we will update prev only if the current node value is not equal to the target value. and the current node will be updated at every iteration
1 parent593b735 commit083ce97

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

‎linked_lists/linked_list.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def delete(self, value):
5252
prev.set_next(current.get_next())
5353
else:
5454
self.head_=current.get_next()
55-
prev=current
55+
else
56+
prev=current
5657
current=current.get_next()
5758

5859
# Pushes an item on the front of the list.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp