Two Sigma Interview Question

Recursive graph function