LeetCode Entry
94. Binary Tree Inorder Traversal
Inorder traversal
94. Binary Tree Inorder Traversal easy
blog post
substack
youtube

Join me on Telegram
https://t.me/leetcode_daily_unstoppable/433
Problem TLDR
Inorder traversal
Intuition
Nothing special. For the iterative solution we can use Morris traversal.
Complexity
-
Time complexity: \(O(n)\)
-
Space complexity: \(O(n)\)
Code
fun inorderTraversal(root: TreeNode?): List<Int> = root?.run {
inorderTraversal(left) + listOf(`val`) + inorderTraversal(right)
} ?: listOf<Int>()