Files
Ikko Eltociear Ashimine 954c45864b docs: add Japanese translate documents (#1812)
* docs: add Japanese documents (`ja/docs`)

* docs: add Japanese documents (`ja/codes`)

* docs: add Japanese documents

* Remove pythontutor blocks in ja/

* Add an empty at the end of each markdown file.

* Add the missing figures (use the English version temporarily).

* Add index.md for Japanese version.

* Add index.html for Japanese version.

* Add missing index.assets

* Fix backtracking_algorithm.md for Japanese version.

* Add avatar_eltociear.jpg. Fix image links on the Japanese landing page.

* Add the Japanese banner.

---------

Co-authored-by: krahets <krahets@163.com>
2025-10-17 05:04:43 +08:00

32 lines
804 B
Python

"""
File: list_node.py
Created Time: 2021-12-11
Author: krahets (krahets@163.com)
"""
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