Problem 2.1: Store Digits (100pts)
Problem
Write a function
store_digitsthat takes in an integernand returns a linked list where each element of the list is a digit ofn. Your solution should run in Linear time in the length of its input.
编写一个函数 store_digits,它接受一个整数 \(n\),并返回一个链表,其中链表的每个元素是 \(n\) 的一个数字。你的解决方案的运行时间应与输入 \(n\) 的长度成线性关系。
def store_digits(n):
"""Stores the digits of a positive number n in a linked list.
>>> s = store_digits(0)
>>> s
Link(0)
>>> store_digits(2345)
Link(2, Link(3, Link(4, Link(5))))
>>> store_digits(8760)
Link(8, Link(7, Link(6, Link(0))))
"""
"*** YOUR CODE HERE ***"