2024每日刷题(一零三)
Leetcode—1265. 逆序打印不可变链表
实现代码
/*** // This is the ImmutableListNode's API interface.* // You should not implement it, or speculate about its implementation.* class ImmutableListNode {* public:* void printValue(); // print the value of the node.* ImmutableListNode* getNext(); // return the next node.* };*/class Solution {
public:void printLinkedListInReverse(ImmutableListNode* head) {if(head == nullptr) {return;}printLinkedListInReverse(head->getNext());head->printValue();}
};
运行结果
之后我会持续更新,如果喜欢我的文章,请记得一键三连哦,点赞关注收藏,你的每一个赞每一份关注每一次收藏都将是我前进路上的无限动力 !!!↖(▔▽▔)↗感谢支持!