Skip to content

Instantly share code, notes, and snippets.

@Dima564
Last active November 1, 2016 13:14
Show Gist options
  • Save Dima564/b0d1b283f2211f199cc88ecf0dac5920 to your computer and use it in GitHub Desktop.
Save Dima564/b0d1b283f2211f199cc88ecf0dac5920 to your computer and use it in GitHub Desktop.
fun flatTree(tree: TreeNode): List<TreeNode>
= listOf(tree, *tree.children.flatMap(::flatTree).toTypedArray())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment