Hello Leetcode community.
I plan to collect Amazon OOD questions in one post and provide them solutions.
In particular, i have seen that currently "Design Unix File Search API" question is very popular problem in Amazon interviews, hence it is the first problem in this post.
Problem statement:
Design Unix File Search API to search file with different arguments as "extension", "name", "size" ...
The design should be maintainable to add new contraints.
Which pattern you should use?
Answer: Specification pattern, create for each criteria a specification class
Follow up: How would you handle if some contraints should support AND, OR conditionals.
I did not provided it yet. Even though below solution took 30 minutes. Solution: use Specification pattern.
I skipped some Getters/Setters to keep code simple, because you can do it yourself.
Solution is simple, it is better do not overengineer. Better for you and interviewer to understand.
Please add any suggestions/improvements and i will apply and update my post.
This is my first design post and please be reasonable in your comments.
Solution:
List of others OODs collected by @goCoronaGo
Another list from @242jainabhi: