×

Instructions

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.


Smart Folder Organiser – Find Folder Depth Binary Trees (Difficulty - Medium)


Smart Folder Organizer – Find Folder Depth

Problem Statement:

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.

Input:

A list of strings representing the folder tree in level order (BFS traversal). Each value is either:

  • A folder name (non-empty string)
  • "null" to represent a missing folder at that position

Output:

An integer representing the maximum depth of the folder structure.

Constraints:

  • 0 ≤ number of folders ≤ 10⁴
  • Each folder name is a non-empty string
  • The structure represents a valid binary tree

Example 1:

Input: ["Main", "Left", "Right"]
Output: 2

Explanation:
"Main" has two subfolders.
Longest path is: Main → Left (or Right) → depth 2.
    

Example 2:

Input: ["Root", "null", "Folder1", "null", "Folder2"]
Output: 3

Explanation:
This is a right-skewed tree:
Root → Folder1 → Folder2 → depth 3.
    

Example 3:

Input: []
Output: 0

Explanation:
The system contains no folders.
    

Example 4:

Input: ["Main", "Left", "Right", "null", "null", "SubRight"]
Output: 3

Explanation:
"SubRight" is the left child of "Right".
Longest path: Main → Right → SubRight → depth 3.
    


Time Left:



Processing...

Error:


                

Output:

Test Case Result Input Correct Output Your Output




Submission Result