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

43 lines
851 B
C++

/**
* File: list_node.hpp
* Created Time: 2021-12-19
* Author: krahets ([email protected])
*/
#pragma once
#include <iostream>
#include <vector>
using namespace std;
/* 연결 리스트 노드 */
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(nullptr) {
}
};
/* 리스트를 연결 리스트로 역직렬화 */
ListNode *vecToLinkedList(vector<int> list) {
ListNode *dum = new ListNode(0);
ListNode *head = dum;
for (int val : list) {
head->next = new ListNode(val);
head = head->next;
}
return dum->next;
}
/* 연결 리스트에 할당한 메모리 공간을 해제한다 */
void freeMemoryLinkedList(ListNode *cur) {
// 메모리 해제
ListNode *pre;
while (cur != nullptr) {
pre = cur;
cur = cur->next;
delete pre;
}
}