blob: 38c058814d579ee7c00cf7f2f498ca0df8dac71b [file]
sealed class Tree {
object Empty: Tree()
class Leaf(val x: Int): Tree()
class Node(val left: Tree, val right: Tree): Tree()
fun max(): Int = when(this) {
is Empty -> -1
is Leaf -> this.x
is Node -> this.left.max()
}
}