Solve tree partition and IPO allocation | Two Sigma Interview Question