Files
Yudong Jin 2f561d3d51 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
2026-10-29 03:46:43 +08:00

33 lines
833 B
C#

// File: ListNode.cs
// Created Time: 2022-12-16
// Author: mingXta ([email protected])
namespace hello_algo.utils;
/* 연결 리스트 노드 */
public class ListNode(int x) {
public int val = x;
public ListNode? next;
/* 배열을 역직렬화하여 연결 리스트로 변환한다 */
public static ListNode? ArrToLinkedList(int[] arr) {
ListNode dum = new(0);
ListNode head = dum;
foreach (int val in arr) {
head.next = new ListNode(val);
head = head.next;
}
return dum.next;
}
public override string? ToString() {
List<string> list = [];
var head = this;
while (head != null) {
list.Add(head.val.ToString());
head = head.next;
}
return string.Join("->", list);
}
}