[LeetCode][Python3] 328. Odd Even Linked List
2019. 1. 25. 00:26 |
프로그래밍/LeetCode
Problem :
https://leetcode.com/problems/odd-even-linked-list/
My Solution :
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def oddEvenList(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if head:
odd = head
even = even_head = head.next
while even and even.next:
odd.next = even.next
odd = odd.next
even.next = odd.next
even = even.next
odd.next = even_head
return head
'프로그래밍 > LeetCode' 카테고리의 다른 글
[LeetCode][Python3] 240. Search a 2D Matrix II (0) | 2019.02.09 |
---|---|
[LeetCode][Python3] 103. Binary Tree Zigzag Level Order Traversal (0) | 2019.02.07 |
[LeetCode][Python3] 279. Perfect Squares (0) | 2019.01.31 |
[LeetCode][Python3] 162. Find Peak Element (0) | 2019.01.25 |
[LeetCode][Python3] 287. Find the Duplicate Number (0) | 2019.01.25 |
[LeetCode][Python3] 75. Sort Colors (0) | 2019.01.24 |
[LeetCode][Python3] 102. Binary Tree Level Order Traversal (0) | 2019.01.22 |
[LeetCode][Python3] 230. Kth Smallest Element in a BST (0) | 2019.01.15 |
최근에 달린 댓글 최근에 달린 댓글