Last active
January 4, 2022 00:39
-
-
Save yairzaslavsky/20fb544c0984c6afa1f7ee6090531b2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TreeNode(var `val`: Int) { | |
var left: TreeNode? = null | |
var right: TreeNode? = null | |
} | |
fun main(args: Array<String>) { | |
val root = TreeNode(1).apply { | |
left = TreeNode(2).apply { // left child of 1 | |
left = TreeNode(4) // left child of 2 | |
} | |
right = TreeNode(3).apply { // right child of 1 | |
right = TreeNode(5).apply { // right child of 3 | |
left = TreeNode(6) // left child of 5 | |
right = TreeNode(7) // right child of 5 | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment