Chapter 7: Stack Challenges
func printInReverse<T>(_ list: LinkedList<T>) {
var current = list.head
var stack = Stack<T>()
while let node = current {
stack.push(node.value)
current = node.next
}
while let value = stack.pop() {
print(value)
}
}Last updated