Amazon interview question

Graph algos and adhoc maths