Files
hello-algo/ja/codes/java/utils/ListNode.java
T
Yudong JinandClaude Opus 5.5 bcd86fc1ed Cite demo-source regions for heap operations and the linked-list node classes (#2036)
Batch 3a of the runnable-snippets plan. heap_operations now cites the heap
demos in Python, C++, Java, C#, Go, Swift, Rust and Kotlin; the demos call
the library directly instead of push/pop helpers and print each popped value.
list_node_class cites each language's shared ListNode (Swift stays literal)
and doubly_list_node_class cites linkedlist_deque (Go stays literal).

Node comments adopt reviewed source wording, Rust and Swift get import
regions, the Ruby typo 前躯 becomes 前驱, and the TypeScript doubly node
fields become nullable. en, ja, ko and zh-hant are regenerated; ru is
synced by hand.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 05:23:41 +08:00

33 lines
778 B
Java

/**
* File: ListNode.java
* Created Time: 2022-11-25
* Author: krahets ([email protected])
*/
package utils;
// [region]{list_node}
/* 連結リストのノード */
public class ListNode {
public int val; // ノードの値
public ListNode next; // 次のノードへの参照
public ListNode(int x) {
val = x;
}
// [endregion]{list_node}
/* リストをデシリアライズして連結リストにする */
public static ListNode arrToLinkedList(int[] arr) {
ListNode dum = new ListNode(0);
ListNode head = dum;
for (int val : arr) {
head.next = new ListNode(val);
head = head.next;
}
return dum.next;
}
// [region]{list_node_end}
}
// [endregion]{list_node_end}