Two Sigma interview question

Recursive graph function