Please read the instructions carefully before starting the exam.
Once you start the exam, the timer will begin, and you cannot pause it.
Ensure that you complete and submit your code within the given time if the timer is enabled.
In a smart file management system, folders are organized in a hierarchical binary structure.
Each folder is represented as a node in a binary tree and can have up to two subfolders: left
and right
.
The depth of the system is defined as the number of folders along the longest path from the root folder to the most deeply nested subfolder.
Your task is to compute the maximum folder depth.
A list of strings representing the folder tree in level order (BFS traversal). Each value is either:
"null"
to represent a missing folder at that positionAn integer representing the maximum depth of the folder structure.
0 ≤ number of folders ≤ 10⁴
Input: ["Main", "Left", "Right"] Output: 2 Explanation: "Main" has two subfolders. Longest path is: Main → Left (or Right) → depth 2.
Input: ["Root", "null", "Folder1", "null", "Folder2"] Output: 3 Explanation: This is a right-skewed tree: Root → Folder1 → Folder2 → depth 3.
Input: [] Output: 0 Explanation: The system contains no folders.
Input: ["Main", "Left", "Right", "null", "null", "SubRight"] Output: 3 Explanation: "SubRight" is the left child of "Right". Longest path: Main → Right → SubRight → depth 3.