ThousandEyes Interview Question

Hard problem and how you solved it