MCPcopy Create free account
hub / github.com/EricPengShuai/Interview / listNodeToString

Function listNodeToString

memo/listnode.cpp:95–106  ·  view source on GitHub ↗

链表转字符串

Source from the content-addressed store, hash-verified

93
94// 链表转字符串
95string listNodeToString(ListNode* node) {
96 if (node == nullptr) {
97 return "[]";
98 }
99
100 string result;
101 while (node) {
102 result += to_string(node->val) + ", ";
103 node = node->next;
104 }
105 return "[" + result.substr(0, result.length() - 2) + "]";
106}
107
108
109int main() {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected