题解 | #牛牛的单链表求和#

牛牛的单链表求和

https://www.nowcoder.com/practice/a674715b6b3845aca0d5009bc27380b5

n = int(input())
lt = list(map(int,input().split()))
class Node:
    def __init__(self, val, next=None):
        self.val = val
        self.next = next
total = lt[0]
head = Node(lt[0])
for i in lt[1:]:
    total += i
    head.next = Node(i)
    head = head.next
print(total)

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务