Google Interview Question

Medium hard question on graphs