mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-04 11:44:21 +00:00
Re-translate the Japanese version (#1871)
* Retranslate Japanese docs with GPT-5.4 * Retranslate Japanese code with GPT-5.4
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* File: ListNode.js
|
||||
* Created Time: 2022-12-12
|
||||
* Author: IsChristina (christinaxia77@foxmail.com)
|
||||
*/
|
||||
|
||||
/* 連結リストノード */
|
||||
class ListNode {
|
||||
val; // ノード値
|
||||
next; // 次のノードを指す参照(ポインタ)
|
||||
constructor(val, next) {
|
||||
this.val = val === undefined ? 0 : val;
|
||||
this.next = next === undefined ? null : next;
|
||||
}
|
||||
}
|
||||
|
||||
/* リストを連結リストにデシリアライズする */
|
||||
function arrToLinkedList(arr) {
|
||||
const dum = new ListNode(0);
|
||||
let head = dum;
|
||||
for (const val of arr) {
|
||||
head.next = new ListNode(val);
|
||||
head = head.next;
|
||||
}
|
||||
return dum.next;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ListNode,
|
||||
arrToLinkedList,
|
||||
};
|
||||
Reference in New Issue
Block a user