Back to problems

Compute Entity Size and Validate a Hierarchical File System

Object-Oriented Programming · Google · Hard

Given an in-memory collection of filesystem Entity records. Each record has a unique id. There are two kinds: File has a nonnegative size. Directory has a children list holding the IDs of its direct child entities. Implement two routines. Part 1 — Size query For a File, return its own size. For a Directory, return the sum of the sizes of all files reachable by following child references starting from that directory. For a single size query, assume that the entities reachable…

Checking your access…