Back to problems

File System Directory Size Sum

Algorithm · Datadog · Easy

In a virtual file system, files and directories are organized as a tree. Every node is a FileEntry. A file entry contains a non‑negative integer size. A directory entry contains a list of child entries, each of which can be another file or directory. The class hierarchy is defined as follows: Implement a function calculate_total_size that takes a FileEntry as input and returns the total size of all files contained within that entry. If the entry is itself a file, return its…

Checking your access…