Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
leetcode: finished #328
Browse files Browse the repository at this point in the history
  • Loading branch information
xqm32 committed Sep 10, 2023
1 parent f0f99c5 commit 1b05bf5
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions content/leetcode/2023/9.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,49 @@ title: 2023.9
draft: false
---

# 2023.9.10

```python
#
# @lc app=leetcode.cn id=328 lang=python3
#
# [328] 奇偶链表
#

from typing import Optional


class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next


# @lc code=start
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def oddEvenList(self, head: Optional[ListNode]) -> Optional[ListNode]:
if not head:
return head
odd, even = head, head.next
evenHead = even
while even and even.next:
odd.next = even.next
even.next = even.next.next
odd = odd.next
even = even.next

odd.next = evenHead
return head


# @lc code=end
```

# 2023.9.9

```python
Expand Down

0 comments on commit 1b05bf5

Please sign in to comment.