Input: "dir\n dir2\n dir3\n \image.jpeg"
Find the sum of file path lengths leading to image files (.jpeg, .jpg, .png).
The spaces represent the depth in the file path. There could be file paths leading to a .txt file but you don't care about those.
Should be solved in O(n) time.
Actually, every directory structure is a tree (assuming Unix). They are asking sum of all depths of leaf nodes that ends with .jpeg, .jpg and .png. DFS is an ideal solution. In window, you have multiple roots unlike Unix where it has only one root.