Talabat Interview Question

The question was a dynamic prog question