mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-03 19:52:01 +08:00
feat(ko): add the Korean online edition (#2006)
* feat(ko): add the complete Korean online edition * Use UTF-8 for Python CI output on Windows * Remove print-book promotion from the Korean site * fix(ko): preserve emphasis before Korean particles
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
"""
|
||||
File: list_node.py
|
||||
Created Time: 2021-12-11
|
||||
Author: krahets ([email protected])
|
||||
"""
|
||||
|
||||
|
||||
class ListNode:
|
||||
"""연결 리스트 노드 클래스"""
|
||||
|
||||
def __init__(self, val: int):
|
||||
self.val: int = val # 노드 값
|
||||
self.next: ListNode | None = None # 다음 노드 참조
|
||||
|
||||
|
||||
def list_to_linked_list(arr: list[int]) -> ListNode | None:
|
||||
"""리스트를 연결 리스트로 역직렬화"""
|
||||
dum = head = ListNode(0)
|
||||
for a in arr:
|
||||
node = ListNode(a)
|
||||
head.next = node
|
||||
head = head.next
|
||||
return dum.next
|
||||
|
||||
|
||||
def linked_list_to_list(head: ListNode | None) -> list[int]:
|
||||
"""연결 리스트를 리스트로 직렬화"""
|
||||
arr: list[int] = []
|
||||
while head:
|
||||
arr.append(head.val)
|
||||
head = head.next
|
||||
return arr
|
||||
Reference in New Issue
Block a user