Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Node{
- var next : Node?
- var val : Int
- init(_ val : Int) {
- self.val = val
- }
- }
- func printNode(_ root: Node?) {
- guard let root = root else {
- return
- }
- printNode(root.next)
- print(root.val)
- }
- print()
- let n1 = Node(1)
- let n2 = Node(2)
- let n3 = Node(3)
- let n4 = Node(4)
- n1.next = n2
- n2.next = n3
- n3.next = n4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement