Apify Interview Question

How to scale this algorithmic task solution?