【发布时间】:2019-03-12 10:41:13
【问题描述】:
编写一个程序,在给定前导指针的情况下,用python中以链表形式表示的两个数字相减。
【问题讨论】:
-
Welcome ot SO 不幸的是,SO 不是一个代码编写服务,您必须展示您尝试过的内容并给出您遇到的特定错误或问题。请阅读stackoverflow.com/help/asking
标签: python-3.x algorithm linked-list
编写一个程序,在给定前导指针的情况下,用python中以链表形式表示的两个数字相减。
【问题讨论】:
标签: python-3.x algorithm linked-list
我将假设您有链接列表的类,但如果您需要自己定义其中一个类,请告诉我。给定一个链表(比如 LL),您可以说差异仅由头节点(前导指针)数据减去头之后的节点给出。
在 python 中看起来像这样:
# assumed there is some linked list defined like LL
difference = LL.head.data - LL.head.next.data
【讨论】: