mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-24 23:50:45 +08:00
Reverts #2034, #2035, #2036 and #2037. The work will return in a single
reviewed PR that is completed before it merges. The tree equals 8c96e2f30
(#2033).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
29 lines
616 B
Java
29 lines
616 B
Java
/**
|
|
* File: ListNode.java
|
|
* Created Time: 2022-11-25
|
|
* Author: krahets ([email protected])
|
|
*/
|
|
|
|
package utils;
|
|
|
|
/* 連結リストのノード */
|
|
public class ListNode {
|
|
public int val;
|
|
public ListNode next;
|
|
|
|
public ListNode(int x) {
|
|
val = x;
|
|
}
|
|
|
|
/* リストをデシリアライズして連結リストにする */
|
|
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;
|
|
}
|
|
}
|