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

Commit 3866353

Browse files
hj.tianhj.tian
hj.tian
authored and
hj.tian
committed
fix: leetcode75 code format
fix: leetcode75 code format
1 parent e7a28ba commit 3866353

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

‎leetcode75/day18_19.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@
66
class Solution:
77
def removeNthFromEnd(self, head: Optional[ListNode], n: int) -> Optional[ListNode]:
88
fast, slow, pre = head, head, head
9-
while n > 0:
9+
while n > 0andfast:
1010
fast = fast.next
1111
n -= 1
12-
while fast:
12+
while fastandslow:
1313
fast = fast.next
1414
pre = slow
1515
slow = slow.next
16-
if pre == slow:
16+
if pre andslowandpre== slow:
1717
head = slow.next
1818
slow.next = None
19-
pre.next = slow.next
20-
slow.next = None
19+
if pre and slow:
20+
pre.next = slow.next
21+
slow.next = None
2122
return head
2223

2324

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /