#K8501. Maximum Depth of Binary Tree
Maximum Depth of Binary Tree
Maximum Depth of Binary Tree
You are given a binary tree represented in level order as a sequence of space‐separated tokens. The token "null" represents a missing node. Your task is to determine the maximum depth of the binary tree.
The maximum depth is defined as the number of nodes along the longest path from the root node down to the farthest leaf node. For example, the binary tree represented by "1 2 3" has a maximum depth of 2.
Please note that the input is provided via standard input (stdin) and the output should be printed to standard output (stdout). Use appropriate methods in your chosen language to build the binary tree from the level order input and compute its maximum depth.
inputFormat
A single line containing space-separated tokens representing the level order traversal of a binary tree. Use the literal string "null" for absent (missing) nodes. For example:
1 2 3
represents a tree with root 1, left child 2, and right child 3. If the first token is "null", the tree is empty.
outputFormat
An integer representing the maximum depth (i.e., the number of nodes along the longest path from the root to a leaf) of the binary tree.## sample
null
0