Amazon VO Interview Question: Design a Flexible File Search Library

17 Views
No Comments

The Unix find command allows you to search for files under a given directory. You can specify criteria for files you are interested in.

Imagine that you need to write code in a high-level language like Java that does things similar to the find command. I would like you to focus on two use cases at first:

  • Find all files over 5 MB somewhere under a directory.
  • Find all XML files somewhere under a directory.

I would like you to create a library that lets me do this easily. Keep in mind that these are just two use cases, and that the library should be flexible.

This problem is about designing an extensible file search library rather than hard-coding two special cases. A good solution separates directory traversal from file filtering, then uses composable predicates or criteria objects to express rules such as“larger than 5 MB”and“has XML extension.”The key discussion points are API design, flexibility for future filters, and clean separation of concerns.

END
 0