Folder Total Size
folder is a dictionary that describes a folder on disk. Each key is a name; its value is either an integer, the size of a file with that name, or another dictionary of the same shape, a sub-folder, nested to any depth. Return the total size of all files anywhere inside folder, counting files in sub-folders, their sub-folders, and so on. An empty folder has total size 0.
You could keep a list of folders still to visit, but the recursive version is natural: add up the files directly inside, and ask each sub-folder for its own total.
For example, {"a.txt": 10, "docs": {"b.txt": 5, "old": {"c.txt": 1}}} gives 10 + 5 + 1 = 16.
Example 1
a.txt is 10, docs holds b.txt (5) and the folder old, which holds c.txt (1): 10 + 5 + 1 = 16.
Example 2
Two files at the top level, 1 + 2 = 3.
Constraints
folderholds at most 100 files and at most 30 folders in total, countingfolderitself- Folders are nested at most 6 levels deep
0 <= size <= 1000for every file- Names have 1 to 12 lowercase letters or dots and are distinct within a folder
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.