Agorize interview question

Two case studies, not easy