The MovieCatalog class uses a combination of Python's dictionary structure and the SortedDict from the sortedcontainers
library. This allows us to organize movies by genre and year, and optimizes lookup times when querying the movies.
This combined structure enables efficient queries by both genre and year. Because SortedDict is implemented as a self-balancing binary search tree (BST), the lookup times for querying a specific year are O(log n), with n being the number of unique years (keys) in the dataset. In our get_movies method, the time complexity is O(klog n + m), where k is the query range of years, n is the number of unique years, and m is the number of movies in the specified range of years.
Run unit test:
python3 -m unittest unit_test.py